Anton Tarasenko
2 years ago
8 changed files with 396 additions and 3 deletions
@ -0,0 +1,41 @@ |
|||||||
|
/** |
||||||
|
* Signal class implementation for `InteractionAPI`'s `OnPreRender` and |
||||||
|
* `OnPostRender` signals. |
||||||
|
* Copyright 2022 Anton Tarasenko |
||||||
|
*------------------------------------------------------------------------------ |
||||||
|
* This file is part of Acedia. |
||||||
|
* |
||||||
|
* Acedia is free software: you can redistribute it and/or modify |
||||||
|
* it under the terms of the GNU General Public License as published by |
||||||
|
* the Free Software Foundation, version 3 of the License, or |
||||||
|
* (at your option) any later version. |
||||||
|
* |
||||||
|
* Acedia is distributed in the hope that it will be useful, |
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||||
|
* GNU General Public License for more details. |
||||||
|
* |
||||||
|
* You should have received a copy of the GNU General Public License |
||||||
|
* along with Acedia. If not, see <https://www.gnu.org/licenses/>. |
||||||
|
*/ |
||||||
|
class Interaction_OnRender_Signal extends Signal; |
||||||
|
|
||||||
|
public function bool Emit(Canvas canvas) |
||||||
|
{ |
||||||
|
local Slot nextSlot; |
||||||
|
|
||||||
|
StartIterating(); |
||||||
|
nextSlot = GetNextSlot(); |
||||||
|
while (nextSlot != none) |
||||||
|
{ |
||||||
|
Interaction_OnRender_Slot(nextSlot).connect(canvas); |
||||||
|
nextSlot = GetNextSlot(); |
||||||
|
} |
||||||
|
CleanEmptySlots(); |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
defaultproperties |
||||||
|
{ |
||||||
|
relatedSlotClass = class'Interaction_OnRender_Slot' |
||||||
|
} |
@ -0,0 +1,41 @@ |
|||||||
|
/** |
||||||
|
* Signal class implementation for `InteractionAPI`'s `OnPreRender` and |
||||||
|
* `OnPostRender` signals. |
||||||
|
* Copyright 2022 Anton Tarasenko |
||||||
|
*------------------------------------------------------------------------------ |
||||||
|
* This file is part of Acedia. |
||||||
|
* |
||||||
|
* Acedia is free software: you can redistribute it and/or modify |
||||||
|
* it under the terms of the GNU General Public License as published by |
||||||
|
* the Free Software Foundation, version 3 of the License, or |
||||||
|
* (at your option) any later version. |
||||||
|
* |
||||||
|
* Acedia is distributed in the hope that it will be useful, |
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||||
|
* GNU General Public License for more details. |
||||||
|
* |
||||||
|
* You should have received a copy of the GNU General Public License |
||||||
|
* along with Acedia. If not, see <https://www.gnu.org/licenses/>. |
||||||
|
*/ |
||||||
|
class Interaction_OnRender_Slot extends Slot; |
||||||
|
|
||||||
|
delegate connect(Canvas canvas) |
||||||
|
{ |
||||||
|
DummyCall(); |
||||||
|
} |
||||||
|
|
||||||
|
protected function Constructor() |
||||||
|
{ |
||||||
|
connect = none; |
||||||
|
} |
||||||
|
|
||||||
|
protected function Finalizer() |
||||||
|
{ |
||||||
|
super.Finalizer(); |
||||||
|
connect = none; |
||||||
|
} |
||||||
|
|
||||||
|
defaultproperties |
||||||
|
{ |
||||||
|
} |
@ -0,0 +1,79 @@ |
|||||||
|
/** |
||||||
|
* Default Acedia implementation for `InteractionAPIBase`. |
||||||
|
* Copyright 2022 Anton Tarasenko |
||||||
|
*------------------------------------------------------------------------------ |
||||||
|
* This file is part of Acedia. |
||||||
|
* |
||||||
|
* Acedia is free software: you can redistribute it and/or modify |
||||||
|
* it under the terms of the GNU General Public License as published by |
||||||
|
* the Free Software Foundation, version 3 of the License, or |
||||||
|
* (at your option) any later version. |
||||||
|
* |
||||||
|
* Acedia is distributed in the hope that it will be useful, |
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||||
|
* GNU General Public License for more details. |
||||||
|
* |
||||||
|
* You should have received a copy of the GNU General Public License |
||||||
|
* along with Acedia. If not, see <https://www.gnu.org/licenses/>. |
||||||
|
*/ |
||||||
|
class InteractionAPI extends InteractionAPIBase; |
||||||
|
|
||||||
|
/* SIGNAL */ |
||||||
|
public function Interaction_OnRender_Slot OnPreRender(AcediaObject receiver) |
||||||
|
{ |
||||||
|
local AcediaInteraction interaction; |
||||||
|
|
||||||
|
// Simple redirect to `AcediaInteraction` |
||||||
|
interaction = class'AcediaInteraction'.static.GetInstance(); |
||||||
|
if (interaction != none) { |
||||||
|
return interaction.OnPreRender(receiver); |
||||||
|
} |
||||||
|
return none; |
||||||
|
} |
||||||
|
|
||||||
|
/* SIGNAL */ |
||||||
|
public function Interaction_OnRender_Slot OnPostRender(AcediaObject receiver) |
||||||
|
{ |
||||||
|
local AcediaInteraction interaction; |
||||||
|
|
||||||
|
// Simple redirect to `AcediaInteraction` |
||||||
|
interaction = class'AcediaInteraction'.static.GetInstance(); |
||||||
|
if (interaction != none) { |
||||||
|
return interaction.OnPostRender(receiver); |
||||||
|
} |
||||||
|
return none; |
||||||
|
} |
||||||
|
|
||||||
|
public function Interaction AddInteraction(BaseText interactionClass) |
||||||
|
{ |
||||||
|
local string classAsString; |
||||||
|
|
||||||
|
if (interactionClass == none) { |
||||||
|
return none; |
||||||
|
} |
||||||
|
classAsString = interactionClass.ToString(); |
||||||
|
return AddInteraction_S(classAsString); |
||||||
|
} |
||||||
|
|
||||||
|
public function Interaction AddInteraction_S(string interactionClass) |
||||||
|
{ |
||||||
|
local Interaction newInteraction; |
||||||
|
local Player player; |
||||||
|
local PlayerController localPlayerController; |
||||||
|
|
||||||
|
localPlayerController = _client.unreal.GetLocalPlayer(); |
||||||
|
if (localPlayerController == none) return none; |
||||||
|
player = localPlayerController.player; |
||||||
|
if (player == none) return none; |
||||||
|
if (player.interactionMaster == none) return none; |
||||||
|
|
||||||
|
newInteraction = player.interactionMaster.AddInteraction( |
||||||
|
"AcediaCore.AcediaInteraction", |
||||||
|
player); |
||||||
|
return newInteraction; |
||||||
|
} |
||||||
|
|
||||||
|
defaultproperties |
||||||
|
{ |
||||||
|
} |
@ -0,0 +1,74 @@ |
|||||||
|
/** |
||||||
|
* API that provides `Interaction` events and auxiliary methods. |
||||||
|
* Copyright 2022 Anton Tarasenko |
||||||
|
*------------------------------------------------------------------------------ |
||||||
|
* This file is part of Acedia. |
||||||
|
* |
||||||
|
* Acedia is free software: you can redistribute it and/or modify |
||||||
|
* it under the terms of the GNU General Public License as published by |
||||||
|
* the Free Software Foundation, version 3 of the License, or |
||||||
|
* (at your option) any later version. |
||||||
|
* |
||||||
|
* Acedia is distributed in the hope that it will be useful, |
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||||
|
* GNU General Public License for more details. |
||||||
|
* |
||||||
|
* You should have received a copy of the GNU General Public License |
||||||
|
* along with Acedia. If not, see <https://www.gnu.org/licenses/>. |
||||||
|
*/ |
||||||
|
class InteractionAPIBase extends AcediaObject; |
||||||
|
|
||||||
|
/** |
||||||
|
* Called before rendering, when `Interaction`s receive their `PreRender()` |
||||||
|
* events |
||||||
|
* |
||||||
|
* [Signature] |
||||||
|
* <slot>(Canvas canvas) |
||||||
|
* |
||||||
|
* @param Canvas `Actor` that attempts to broadcast next text message. |
||||||
|
*/ |
||||||
|
/* SIGNAL */ |
||||||
|
public function Interaction_OnRender_Slot OnPreRender(AcediaObject receiver); |
||||||
|
|
||||||
|
/** |
||||||
|
* Called before rendering, when `Interaction`s receive their `PreRender()` |
||||||
|
* events |
||||||
|
* |
||||||
|
* [Signature] |
||||||
|
* <slot>(Canvas canvas) |
||||||
|
* |
||||||
|
* @param Canvas `Actor` that attempts to broadcast next text message. |
||||||
|
*/ |
||||||
|
/* SIGNAL */ |
||||||
|
public function Interaction_OnRender_Slot OnPostRender(AcediaObject receiver); |
||||||
|
|
||||||
|
/** |
||||||
|
* Adds new interaction of class `interactionClass` to the local interaction |
||||||
|
* master. |
||||||
|
* |
||||||
|
* @see `AddInteraction_S()` |
||||||
|
* |
||||||
|
* @param interactionClass Textual representation of interaction class |
||||||
|
* to add. |
||||||
|
* @return Newly added interaction. `none` if we've failed to add it to |
||||||
|
* the interaction master. |
||||||
|
*/ |
||||||
|
public function Interaction AddInteraction(BaseText interactionClass); |
||||||
|
|
||||||
|
/** |
||||||
|
* Adds new interaction of class `interactionClass` to the local interaction |
||||||
|
* master. |
||||||
|
* |
||||||
|
* @see `AddInteraction()` |
||||||
|
* |
||||||
|
* @param interactionClass Textual representation of interaction class |
||||||
|
* to add. |
||||||
|
* @return Newly added interaction. `none` if we've failed to add it to |
||||||
|
* the interaction master. |
||||||
|
*/ |
||||||
|
public function Interaction AddInteraction_S(string interactionClass); |
||||||
|
|
||||||
|
defaultproperties |
||||||
|
{ |
||||||
|
} |
@ -0,0 +1,120 @@ |
|||||||
|
/** |
||||||
|
* Acedia's interaction class that allows it access to drawing and user input. |
||||||
|
* Copyright 2022 Anton Tarasenko |
||||||
|
*------------------------------------------------------------------------------ |
||||||
|
* This file is part of Acedia. |
||||||
|
* |
||||||
|
* Acedia is free software: you can redistribute it and/or modify |
||||||
|
* it under the terms of the GNU General Public License as published by |
||||||
|
* the Free Software Foundation, version 3 of the License, or |
||||||
|
* (at your option) any later version. |
||||||
|
* |
||||||
|
* Acedia is distributed in the hope that it will be useful, |
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||||
|
* GNU General Public License for more details. |
||||||
|
* |
||||||
|
* You should have received a copy of the GNU General Public License |
||||||
|
* along with Acedia. If not, see <https://www.gnu.org/licenses/>. |
||||||
|
*/ |
||||||
|
class AcediaInteraction extends Interaction; |
||||||
|
|
||||||
|
#exec OBJ LOAD FILE=KillingFloorHUD.utx |
||||||
|
#exec OBJ LOAD FILE=KillingFloor2HUD.utx |
||||||
|
|
||||||
|
var private Global _; |
||||||
|
var private ClientGlobal _client; |
||||||
|
var private AcediaInteraction myself; |
||||||
|
var Texture shield; |
||||||
|
|
||||||
|
var private Interaction_OnRender_Signal onPreRenderSignal; |
||||||
|
var private Interaction_OnRender_Signal onPostRenderSignal; |
||||||
|
|
||||||
|
/** |
||||||
|
* Called before rendering, when `Interaction`s receive their `PreRender()` |
||||||
|
* events |
||||||
|
* |
||||||
|
* [Signature] |
||||||
|
* <slot>(Canvas canvas) |
||||||
|
* |
||||||
|
* @param Canvas `Actor` that attempts to broadcast next text message. |
||||||
|
*/ |
||||||
|
/* SIGNAL */ |
||||||
|
public function Interaction_OnRender_Slot OnPreRender(AcediaObject receiver) |
||||||
|
{ |
||||||
|
return Interaction_OnRender_Slot(onPreRenderSignal.NewSlot(receiver)); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Called before rendering, when `Interaction`s receive their `PreRender()` |
||||||
|
* events |
||||||
|
* |
||||||
|
* [Signature] |
||||||
|
* <slot>(Canvas canvas) |
||||||
|
* |
||||||
|
* @param Canvas `Actor` that attempts to broadcast next text message. |
||||||
|
*/ |
||||||
|
/* SIGNAL */ |
||||||
|
public function Interaction_OnRender_Slot OnPostRender(AcediaObject receiver) |
||||||
|
{ |
||||||
|
return Interaction_OnRender_Slot(onPostRenderSignal.NewSlot(receiver)); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Initializes newly created `Interaction`. |
||||||
|
*/ |
||||||
|
public final function InitializeInteraction() |
||||||
|
{ |
||||||
|
if (default.myself != none) { |
||||||
|
return; |
||||||
|
} |
||||||
|
default.myself = self; |
||||||
|
_ = class'Global'.static.GetInstance(); |
||||||
|
_client = class'ClientGlobal'.static.GetInstance(); |
||||||
|
onPreRenderSignal = Interaction_OnRender_Signal( |
||||||
|
_.memory.Allocate(class'Interaction_OnRender_Signal')); |
||||||
|
onPostRenderSignal = Interaction_OnRender_Signal( |
||||||
|
_.memory.Allocate(class'Interaction_OnRender_Signal')); |
||||||
|
} |
||||||
|
|
||||||
|
event NotifyLevelChange() |
||||||
|
{ |
||||||
|
_.environment.ShutDown(); |
||||||
|
default.myself = none; |
||||||
|
_ = none; |
||||||
|
_client = none; |
||||||
|
master.RemoveInteraction(self); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Returns instance to the added `AcediaInteraction`'s instance. |
||||||
|
* |
||||||
|
* @return Instance added to interaction master. |
||||||
|
*/ |
||||||
|
public static function AcediaInteraction GetInstance() |
||||||
|
{ |
||||||
|
return default.myself; |
||||||
|
} |
||||||
|
|
||||||
|
public function PreRender(Canvas canvas) |
||||||
|
{ |
||||||
|
if (onPreRenderSignal != none) { |
||||||
|
onPreRenderSignal.Emit(canvas); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public function PostRender(Canvas canvas) |
||||||
|
{ |
||||||
|
Log("dsfsdfs"); |
||||||
|
canvas.SetPos(500, 500); |
||||||
|
canvas.DrawTile(shield, 16, 16, 0, 0, shield.MaterialUSize(), shield.MaterialVSize()); |
||||||
|
if (onPostRenderSignal != none) { |
||||||
|
onPostRenderSignal.Emit(canvas); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
defaultproperties |
||||||
|
{ |
||||||
|
shield = Texture'KillingFloorHUD.HUD.Hud_Shield' |
||||||
|
bVisible = true |
||||||
|
} |
Loading…
Reference in new issue