So I have setup base shorcut/hot bar logic in my Character class:
Here I assign objects:
void ARPGCharacter::SetCurrentAbility(ARPGAbility* NewAbility)
{
if(NewAbility)
{
//we don't want to override already assigned object. So if it is null we pass
//it's very bad way of doing this. I think.
if(!ActionButtonOneObj)
{
ActionButtonOneObj = NewAbility;
}
else if (!ActionButtonTwoObj)
{
ActionButtonTwoObj = NewAbility;
}
}
}
And here I execute actions on assigned objects:
void ARPGCharacter::ActionButtonOne()
{
ARPGPlayerController* PC = Cast(Controller);
if(PC)
{
ActionButtonOneObj->OnCast();
}
}
void ARPGCharacter::ActionButtonTwo()
{
ARPGPlayerController* PC = Cast(Controller);
if(PC)
{
ActionButtonTwoObj->OnCast();
}
}
BIND_ACTION(InputComponent, "ActionButtonOne", IE_Pressed, &ARPGCharacter::ActionButtonOne);
BIND_ACTION(InputComponent, "ActionButtonTwo", IE_Pressed, &ARPGCharacter::ActionButtonTwo);
It’s pretty bad and hard coded, but I was trying to get concept working.
What I really like to do is to:
Create slate UI element.
Bind this element to input action (or rather action to Slate). So functions ActionButtonOne() etc won’t be called directly but rather trough slate.So each slate button, would have assigned exactly one action. And pressing key on keyboard will call slate button, which will call assigned function.
Assign object trough slate. Button doesn’t really know what to do. What it knows, that it should trigger OnCast() event in some ability class. What class exactly is decided during runtime where user can assign particular ability to button.
I’ve got general concept here (I think), that after user drag ability to button (or select it from list), it will be assigned to ActionButtonOneObj, so the corresponding action will know what object exactly should be called.
I will be honest here I completely do not understand Slate. Especially parts about data binding, and how it communicate with other classes (like Pawns). Not looking for ready solution, but some general examples on how to handle data binding, input binding and communication would be very helpful.
Unless I over think issue here, and there is better way to handle this.