Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
2 registered members (OptimusPrime, AndrewAMD), 14,580 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Dynamic Buttons #136894
06/17/07 19:04
06/17/07 19:04
Joined: Jun 2007
Posts: 6
Phoenix, AZ, USA
David_Higgins Offline OP
Newbie
David_Higgins  Offline OP
Newbie

Joined: Jun 2007
Posts: 6
Phoenix, AZ, USA
I'm new to A6, and have been messing around quite a bit with the 2D/Panel portions for an advanced HUD layout ...

I've managed to figure out how to update the BMAP for a Panel on-the-fly, but am failing to find a way to update the BMAP's for a button definition dynamically.

Basically, what I want to do is have a series of panels on the screen, and each of them will contain a different button ... the button however, is dynamic and can change at any given time ... the number of buttons is extremely high and I'd really rather not create ButtonPanel1, ButtonPanel2, ..., ButtonPanel346 ....

What I was hoping to be able to do was:

Code:

PANEL ButonPanel1
{
bmap button_frame;
pos_x = 0;
pos_y = 0;
}

function showButton()
{
// some logic here for determing what graphics to display
ButtonPanel1.Button = 0, 0, on, off, over, fon, foff, fover;
ButtonPanel1.visible = on;
}



However, Panels can apparently have numerous buttons ... and the .Button property does not exist ... there also appears to be no way to reference a button through code ...

any suggestions ... work arounds ... or possibly a doc page that has info related to what I'm trying to do ... ?

Thanks,


-- David Higgins [ Gear Worx Productions / Developer ]
Re: Dynamic Buttons [Re: David_Higgins] #136895
06/17/07 19:33
06/17/07 19:33
Joined: Oct 2004
Posts: 1,655
T
testDummy Offline
Serious User
testDummy  Offline
Serious User
T

Joined: Oct 2004
Posts: 1,655
Yes, I know, again with my stupid plugin. I do dynamic buttons with a plugin. Internally, structure is managed with C++ classes, and panels are simply recreated with pan_create using stored structure, based on modifications to that structure, etc. This means I can move, hide / show, remove, change bmaps for, change functions for, change text for, buttons on the fly. Evidently, pan_create is quick enough to do this. It's been awhile since I've worked on the plugin, but here is a list of exported functions:
Code:

dllfunction fontfGetDx(_font);
dllfunction fontfGetCpl(_font);
dllfunction fontfGetDy(_font);
dllfunction fontfGetNum(_font);
dllfunction fontfGetType(_font, _s);

dllfunction txtfGetAlpha(_txt);
dllfunction txtfGetColor(_txt, _vColor);
dllfunction txtfGetLayer(_txt);
dllfunction txtfGetS(_txt, _txtI, _s);
dllfunction txtfGetSCount(_txt);
dllfunction txtfGetSLen(_txt, _txtI);
dllfunction txtfGetCenterX(_txt);
dllfunction txtfGetCenterY(_txt);
dllfunction txtfGetCondensed(_txt);
dllfunction txtfGetFilter(_txt);
dllfunction txtfGetNarrow(_txt);
dllfunction txtfGetS(_txt, _txtI, _s);
dllfunction txtfGetSP(_txt, _txtI);
dllfunction txtfGetScaleX(_txt);
dllfunction txtfGetScaleY(_txt);
dllfunction txtfGetShadow(_txt);
dllfunction txtfGetTranslucent(_txt);
dllfunction txtfGetVisible(_txt);
dllfunction txtfGetX(_txt);
dllfunction txtfGetY(_txt);

dllfunction txtfSetAlpha(_txt, _alpha);
dllfunction txtfSetCenterX(_txt, _state);
dllfunction txtfSetCenterY(_txt, _state);
dllfunction txtfSetColor(_txt, vColor);
dllfunction txtfSetCondensed(_txt, _state);
dllfunction txtfSetFilter(_txt, _state);
dllfunction txtfSetFont(_txt, _font);
dllfunction txtfSetLayer(_txt, _layer);
dllfunction txtfSetNarrow(_txt, _state);
dllfunction txtfSetPos(_txt, _x, _y);
dllfunction txtfSetS(_txt, _txtI, _s);
dllfunction txtfSetScale(_txt, _scaleX, _scaleY);
dllfunction txtfSetScaleX(_txt, _scaleX);
dllfunction txtfSetScaleY(_txt, _scaleY);
dllfunction txtfSetShadow(_txt, _state);
dllfunction txtfSetTranslucent(_txt, _state);
dllfunction txtfSetVisible(_txt, _state);
dllfunction txtfSetX(_txt, _x);
dllfunction txtfSetY(_txt, _y);

dllfunction uifAdd(_parentIndex, _childIndex);
dllfunction uifAlpha(_index);
dllfunction uifNewB(_sName, _txtEnable, _x, _y);
dllfunction uifNewCb(_sName, _iValue, _x, _y);
dllfunction uifNewLbl(_sName, _txtEnable, _x, _y);
dllfunction uifNewLblT(_sName, _s, _x, _y);
dllfunction uifNewNi(_sName, _x, _y);
dllfunction uifNewP(_x, _y);
dllfunction uifNiI(_panel, _bId);
dllfunction uifGetPnl(_pnl);
dllfunction uifGetBttn(_pnl, _bId);

dllfunction uifChild(_parentIndex, _childIndex);
dllfunction uifColor(_index, _color);
dllfunction uifColorR(_index);
dllfunction uifColorG(_index);
dllfunction uifColorB(_index);
dllfunction uifCount(_index);
dllfunction uifCompile(_index);

dllfunction uifFilter(_index);
dllfunction uifFInc(_index);
dllfunction uifFValue(_index);
dllfunction uifH(_index);
dllfunction uifHasTxt(_index);
dllfunction uifIInc(_index);
dllfunction uifIValue(_index);
dllfunction uifLayer(_index);
dllfunction uifLight(_index);
dllfunction uifMinus(_index);
dllfunction uifMode(_index);
dllfunction uifName(_index, _s);
dllfunction uifOpen(_sDirectory, _sFileName);
dllfunction uifOverlay(_index);
dllfunction uifPanelGet(_panel);
dllfunction uifParent(_index);
dllfunction uifPlus(_index);
dllfunction uifRemove(_index);

dllfunction uifSave(_directory, _filename);
dllfunction uifSetAlpha(_index, _alpha, _propagate);
dllfunction uifSetColor(_index, _red, _green, _blue);
dllfunction uifSetColorR(_index, _red);
dllfunction uifSetColorG(_index, _green);
dllfunction uifSetColorB(_index, _blue);
dllfunction uifSetBmap(_index, _sBmap);
dllfunction uifSetDim(_index, _width, _height);
dllfunction uifSetFilter(_index, _state);
dllfunction uifSetFInc(_index, _fInc);
dllfunction uifSetFont(_index, _font);
dllfunction uifSetFn(_index, _sFnOn, _sFnOff, _sFnOver);
dllfunction uifSetFnOn(_index, _sFn);
dllfunction uifSetFnOff(_index, _sFn);
dllfunction uifSetFnOver(_index, _sFn);
dllfunction uifSetFValue(_index, _fValue);

dllfunction uifSetH(_index, _height);

dllfunction uifSetIInc(_index, _iInc);
dllfunction uifSetImg(_index, _sImgOn, _sImgOff, _sImgOver);
dllfunction uifSetImgAll(_index, _sImg);
dllfunction uifSetImgOn(_index, _sImg);
dllfunction uifSetImgOff(_index, _sImg);
dllfunction uifSetImgOver(_index, _sImg);

dllfunction uifSetIValue(_index, _iValue);

dllfunction uifSetLight(_index, _light);
dllfunction uifSetLayer(_index, _layer, _propagate);
dllfunction uifSetMode(_index, _mode);
dllfunction uifSetPos(_index, _x, _y);
dllfunction uifSetOverlay(_index, _state);
dllfunction uifSetScale(_index, _scaleX, _scaleY, _affectPos);
dllfunction uifSetScaleX(_index, _scaleX, _affectPos);
dllfunction uifSetScaleY(_index, _scaleY, _affectPos);
dllfunction uifSetSpec(_i);

dllfunction uifSetStr(_index, _s);

dllfunction uifSetTxt(_index, _text);
dllfunction uifSetTxtAlpha(_index, _alpha);
dllfunction uifSetTxtColor(_index, _red, _green, _blue);
dllfunction uifSetTxtFactorX(_index, _factorX);
dllfunction uifSetTxtFactorY(_index, _factorY);
dllfunction uifSetTxtLayer(_index, _layer);
dllfunction uifSetTxtPos(_index, _x, _y);
dllfunction uifSetTxtScale(_index, _scaleX, _scaleY);
dllfunction uifSetTxtScaleX(_index, _scaleX);
dllfunction uifSetTxtScaleY(_index, _scaleY);
dllfunction uifSetTxtStr(_index, _txtI, _s);
dllfunction uifSetTxtX(_index, _x);
dllfunction uifSetTxtY(_index, _y);
dllfunction uifSetTxtVis(_index, _visible);

dllfunction uifSetX(_index, _x);
dllfunction uifSetY(_index, _y);
dllfunction uifSetW(_index, _width);
dllfunction uifSetVis(_index, _visible);
dllfunction uifStr(_index, _s);

dllfunction uifType(_index);

dllfunction uifTxtColor(_index _color);
dllfunction uifTxtFactorX(_index);
dllfunction uifTxtFactorY(_index);
dllfunction uifTxtLayer(_index);
dllfunction uifTxtNew(_index, _strings, _layer, _font);
dllfunction uifTxtS(_index, _txtI, _s);
dllfunction uifTxtSP(_index, _txtI);
dllfunction uifTxtVis(_index);
dllfunction uifTxtX(_index);
dllfunction uifTxtY(_index);

dllfunction uifToFile(_sDirectory, _sFileName);
dllfunction uifW(_index);
dllfunction uifX(_index);
dllfunction uifY(_index);
dllfunction uifUpdate(_index);


So the answer, unfortunately, might be function pan_create. It is probably the same with the A6 UI editor written in Lite-C...I noticed that you posted in that thread.
Creating 256 panels and buttons using my plugin might resemble this:
Code:

var i3[3];
i3[0] = 0;
while (i3[0] < 256) {
i3[1] = uifNewP(i3[0] * 3, i3[0] * 3);
i3[2] = uifNewB("b", 0, 0, 0);
uifAdd(i3[1], i3[2]);
uifSetImgAll(i3[2], "b0.pcx");
uifCompile(i3[1]);
i3[0] += 1;
}



Last edited by testDummy; 06/17/07 20:01.
Re: Dynamic Buttons [Re: testDummy] #136896
06/17/07 20:11
06/17/07 20:11
Joined: Jun 2007
Posts: 6
Phoenix, AZ, USA
David_Higgins Offline OP
Newbie
David_Higgins  Offline OP
Newbie

Joined: Jun 2007
Posts: 6
Phoenix, AZ, USA
thanks for the quick reply ... however, my initial attempts at this UI actually were based on pan_create ... however, I found that whenever I tried to dynamically build a string for pan_create I kept getting errors ... and I'm not sure how to resolve them ...

Basically, I was trying to dynamically build the string parameter that defines the panel ... I think I went about it the wrong way though ... probably have to create a local string variable, then use the str* functions to build the string dynamically ... although this is a fairly clunky way to go about making dynamic buttons ... if I were more familiar with the engine SDK ... I might write a custom DLL that can do it ... as I'm sure there's a way to change the buttons in the C++ through the SDK ...

Thanks again for the response ... if anyone else has any other ideas that don't involve writing C++, or building dynamic strings to pass to pan_create ... please let me know.


-- David Higgins [ Gear Worx Productions / Developer ]
Re: Dynamic Buttons [Re: David_Higgins] #136897
06/18/07 01:05
06/18/07 01:05
Joined: Oct 2004
Posts: 1,655
T
testDummy Offline
Serious User
testDummy  Offline
Serious User
T

Joined: Oct 2004
Posts: 1,655
If you are going to use pan_create, I believe you must use the delimiters < > to delimit strings inside of the greater string.
Quote:

as I'm sure there's a way to change the buttons in the C++ through the SDK ...



Quoted David_Higgins.
You know, I would have thought so too, but after examing the SDK, it seems there is only so much access.

In my plugin, panels ARE created using pan_create, a combined string, and information in classes.

I don't think you can actually define strings locally in C-Script.

To change the bmap or position of a button, look up functions
pan_setpos(PANEL*, var type, var num, VECTOR* pos)
pan_setbmap(PANEL*, var num, BMAP*)
in the manual, but you should have already seen that material.

Re: Dynamic Buttons [Re: testDummy] #136898
06/18/07 01:10
06/18/07 01:10
Joined: Jun 2007
Posts: 6
Phoenix, AZ, USA
David_Higgins Offline OP
Newbie
David_Higgins  Offline OP
Newbie

Joined: Jun 2007
Posts: 6
Phoenix, AZ, USA
actually, I've got dynamic bmap changes working already using panel.bmp = new_bmap; ... my issue is that the Panel.bmap property is available to me, but I do not have a Panel.Button property to work with, nor a Panel.Digits for that matter ... so I am unable to swap out the On,Off,Over bitmaps for a Button definition within a panel through C-Script, and the only way I can find to work around this so far is to create a panel Button with a transparent bitmap (seems buttons still have clickable regions within the transparent portion of the image -- only tested once a while back, haven't re-affirmed.).

So ... my work around is to have the Button portion of the panel sitting on say, Layer 10, and have a MouseOver and MouseClick event change the bmap of the actual panel ...

Code:

function swap();
PANEL test_button
{
bmap = some_bmap;
Button = 0, 0, boff, bon, bover, swap, swap, swap;
}

function swap(btn, pnl)
{
// logic to make the swap determination
pnl.bmap = new_bmap;
}
}



This would be a quirky workaround, and most likely lead to cluttered and unmanageable code ... but, in theory, should work ...

Any suggestions or additional work around ideas are greatly appreciated.


-- David Higgins [ Gear Worx Productions / Developer ]
Re: Dynamic Buttons [Re: David_Higgins] #136899
06/19/07 07:05
06/19/07 07:05
Joined: Jun 2007
Posts: 6
Phoenix, AZ, USA
David_Higgins Offline OP
Newbie
David_Higgins  Offline OP
Newbie

Joined: Jun 2007
Posts: 6
Phoenix, AZ, USA
OK, for any one who finds this thread and wonders ... I pulled it off, and here's how ...

Code:

function fn_Click();
function fn_Release();
function fn_Over();
PANEL Card1
{
bmap = card_frame;
Button = 0, 0, img_transparent, img_transparent, img_transparent, fn_Click, fn_Release, fn_Over;
flags = visible;
layer = 2;
}
PANEL Card1Image
{
bmap = card_1_normal;
layer = 1;
}
function fn_Click(btn, pnl)
{
if(pnl == Card1)
{
Card1Image.bmap = card_1_click;
}
}
function fn_Release(btn, pnl)
{
if(pnl == Card1 && event_type == event_release)
{
Card1Image.bmap = card_1_normal;
}
if(pnl == Card1 && event_type == event_mouseup)
{
Card1Image.bmap = card_1_over;
}
}
function fn_Over(btn, pnl)
{
if(pnl == Card1)
{
Card1Image.bmap = card_1_over;
}
}



So, basically ... if card_1_over, _normal and _click are BMAP*'s ... you could essentially create dynamically changing buttons ... say for example a memory card game where each time you lay the cards out the images behind them change ... you know there's 32 cards on the screen ... so you can define constant BMAP* references to card_1 -> card_32 ... and have _normal, _click and _over versions ... so the normal would be the back of the card (the same image for all cards in a memory deck most likely, heh) ... card_click would be the face of the card ... and card_over would maybe be the back of the card with a highlight ...

note, in the fn_Release ... I check the event type ... if the event_type==mouseup ... I go back to the 'over' (hover) state ... cause the mouse is still over the card ...

Hope this finds a use to someone, I know it helped me out ...

If anyone has a better way of doing this, please let me know.


-- David Higgins [ Gear Worx Productions / Developer ]

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1