I see you trying to use new GUI to
remake fixboy screen... it won't be easy or (i think) even possible currently. Well, not without writing whole client<->server communication first, which lays deep into source right now. Not even CustomCall() will help you, as it have nothing related to fixboy at this point.
If you don't want to wait for screen to be put into SDK (where i
really hope communication will be scripted too) i'd recommend to use old/hardcoded screen, and add your buttons/counters into it.
I'd roll with something like that:
- edit default.ini and make a place for your controls
- create .fogui screen with different id than CLIENT_SCREEN_FIXBOY; use the background graphic from default.ini, just to make things easier
- add a GUIPanel in your empty space and add controls you need to it
- when user change amount of items to create, send a fast RunServerScript() which will save the number in critter-related place (bindfield, param, lvar)
- find a way to copy GUIPanel and all its childs from your screen (which will never be seen by user) into old/hardcoded screen and change GUIPanel parent to it
- modify crafting function to respect that number during items spawning
- drop a tear of joy
Once SDK will get a Fixboy.fogui, and it would
not contain multiplier, you already have a code for it so it will be matter of c/p around. If it would have, well... at least you learned something new what may or may not help you in future, or others which are doing transition from old/own gui to one provided in SDK
After posting this i realized i needed something in that manner for myself. Instead of fixboy, i wanted to add something to character screen; just like fixboy it's still hardcoded, so it can be good example. Here it is, injecting VTDB button into character screen after updating 2238 to new gui, with
.fogui file registered as CLIENT_SCREEN_VTDB_CHARACTER.
Cloning GUIPanel, unlike what i though before starting, was easiest part, so let's start with this. At first i tried to keep it inside .fogui but it didn't work well, so i've added this after GUI_EngineCallback_Start()
GUIPanel@ panel = GUI_GetScreen( CLIENT_SCREEN_VTDB_CHARACTER ).FindPanel( "ButtonPanel" );
GUIScreen@ character = GUI_GetScreen( CLIENT_SCREEN_CHARACTER );
if( valid(panel) && valid(character) )
panel._Clone( character );
Easy, right?
After launching the game button and text was in right place and displayed correctly. Until you tried to move character screen - none of my my controls moved with screen... Oh noes!
To fix this, i've set panel position to 0,0 (so child controls won't need extra fixes) and added fetching character screen position on every drawing loop, then setting panel position to it.
int x = 0, y = 0;
GetHardcodedScreenPos( CLIENT_SCREEN_CHARACTER, x, y );
SetPosition( x, y );
Another problem showed up - if you hold pressed button and move mouse, it changed button position... Disaster!
This one took a little time, as i don't know new GUI too well yet, and i didn't want to edit gui_h.fos either. It ended with overriding one of GUI functions responsible for moving object around...
bool AllowMove = true;
void _Move( int deltaX, int deltaY, bool callCallback, bool moveBasePos ) override
{
if( cast<ButtonPanel>(Parent).AllowMove )
GUIObject::_Move( deltaX, deltaY, callCallback, moveBasePos );
}
...and updating panel-positioning function
int x = 0, y = 0;
GetHardcodedScreenPos( CLIENT_SCREEN_CHARACTER, x, y );
AllowMove = true;
SetPosition( x, y );
AllowMove = false;
And bam, button stay in its place and doesn't derp around. Great success!
Hope it will help, if not you then maybe someone else (hi Lidae!) thinking about switching to SDK GUI.