forked from Mirrors/openclonk
parent
bd0bcedd93
commit
337126fcb9
|
@ -11,7 +11,6 @@ local menu_layout;
|
|||
local target;
|
||||
|
||||
// set later
|
||||
local menu_id;
|
||||
local entries;
|
||||
|
||||
func Construction()
|
||||
|
@ -39,7 +38,7 @@ global func CreateClassicMenu(id symbol, object command_object, int extra, strin
|
|||
{
|
||||
Hgt = [0, 32],
|
||||
icon = {Symbol = symbol, Wdt = [0, 32], Hgt = [0, 32]},
|
||||
caption = {X = [0, 32], Text = caption, Style = MENU_TextVCenter}
|
||||
caption = {X = [0, 32], Text = caption, Style = GUI_TextVCenter}
|
||||
},
|
||||
body =
|
||||
{
|
||||
|
@ -47,7 +46,7 @@ global func CreateClassicMenu(id symbol, object command_object, int extra, strin
|
|||
items =
|
||||
{
|
||||
Wdt = 500,
|
||||
Style = MENU_GridLayout
|
||||
Style = GUI_GridLayout
|
||||
},
|
||||
description =
|
||||
{
|
||||
|
@ -59,7 +58,7 @@ global func CreateClassicMenu(id symbol, object command_object, int extra, strin
|
|||
}
|
||||
}
|
||||
};
|
||||
Menu_AddMargin(menu.menu_layout.inner, 15, 15);
|
||||
Gui_AddMargin(menu.menu_layout.inner, 15, 15);
|
||||
return menu;
|
||||
}
|
||||
|
||||
|
@ -76,9 +75,9 @@ public func AddMenuItem(string caption, string command, symbol, int count, param
|
|||
Hgt = [0, 64],
|
||||
Text = Format("%dx", count),
|
||||
Priority = ID,
|
||||
OnClick = MenuAction_Call(this, "OnClick", [symbol, ID, command, parameter]),
|
||||
OnMouseIn = [MenuAction_SetTag(nil, 0, "Hover"), MenuAction_Call(this, "UpdateDesc")],
|
||||
OnMouseOut = MenuAction_SetTag(nil, 0, "Std"),
|
||||
OnClick = GuiAction_Call(this, "OnClick", [symbol, ID, command, parameter]),
|
||||
OnMouseIn = [GuiAction_SetTag(nil, 0, "Hover"), GuiAction_Call(this, "UpdateDesc")],
|
||||
OnMouseOut = GuiAction_SetTag(nil, 0, "Std"),
|
||||
};
|
||||
entries[ID] = [info_caption ?? symbol.Description];
|
||||
|
||||
|
@ -88,18 +87,18 @@ public func AddMenuItem(string caption, string command, symbol, int count, param
|
|||
|
||||
func Open()
|
||||
{
|
||||
return CustomMenuOpen(menu_layout);
|
||||
return CustomGuiOpen(menu_layout);
|
||||
}
|
||||
|
||||
func UpdateDesc(int player, int ID, int subwindowID, object target, data)
|
||||
{
|
||||
var update = { Text = entries[subwindowID][0] };
|
||||
CustomMenuUpdate(update, ID, 1, 0);
|
||||
CustomGuiUpdate(update, ID, 1, 0);
|
||||
}
|
||||
|
||||
func OnClick(int player, int ID, int subwindowID, object target, data)
|
||||
{
|
||||
target->Call(data[2], data[0], data[3]);
|
||||
if (!permanent)
|
||||
CustomMenuClose(ID);
|
||||
CustomGuiClose(ID);
|
||||
}
|
|
@ -10,7 +10,7 @@ local Name = "Grid Menu";
|
|||
func Construction()
|
||||
{
|
||||
inherited(...);
|
||||
this.Style = MENU_GridLayout;
|
||||
this.Style = GUI_GridLayout;
|
||||
}
|
||||
|
||||
// custom_menu_id should be passed if the menu was manually opened and not via Open()
|
||||
|
@ -18,12 +18,12 @@ func AddItem(symbol, string text, user_ID, proplist target, command, parameter,
|
|||
{
|
||||
custom_menu_id = custom_menu_id ?? menu_id;
|
||||
|
||||
var on_hover = MenuAction_SetTag(nil, 0, "OnHover");
|
||||
var on_hover = GuiAction_SetTag(nil, 0, "OnHover");
|
||||
if (on_mouse_over_callback)
|
||||
on_hover = [on_hover, MenuAction_Call(this, "DoCallback", on_mouse_over_callback)];
|
||||
var on_hover_stop = MenuAction_SetTag(nil, 0, "Std");
|
||||
on_hover = [on_hover, GuiAction_Call(this, "DoCallback", on_mouse_over_callback)];
|
||||
var on_hover_stop = GuiAction_SetTag(nil, 0, "Std");
|
||||
if (on_mouse_out_callback)
|
||||
on_hover_stop = [on_hover_stop, MenuAction_Call(this, "DoCallback", on_mouse_out_callback)];
|
||||
on_hover_stop = [on_hover_stop, GuiAction_Call(this, "DoCallback", on_mouse_out_callback)];
|
||||
|
||||
var ID = GetLength(entries) + 1;
|
||||
if (!custom_entry)
|
||||
|
@ -31,12 +31,12 @@ func AddItem(symbol, string text, user_ID, proplist target, command, parameter,
|
|||
custom_entry = {Hgt = [0, 64], Wdt = [0, 64], desc = {Y = [1000, -15]}};
|
||||
custom_entry.Symbol = symbol;
|
||||
custom_entry.desc.Text = text;
|
||||
custom_entry.desc.Style = MENU_TextRight;
|
||||
custom_entry.desc.Style = GUI_TextRight;
|
||||
custom_entry.ID = ID;
|
||||
custom_entry.Target = this;
|
||||
custom_entry.Priority = ID;
|
||||
custom_entry.BackgroundColor = {Std = 0, OnHover = 0x50ff0000};
|
||||
custom_entry.OnClick = MenuAction_Call(this, "OnClick");
|
||||
custom_entry.OnClick = GuiAction_Call(this, "OnClick");
|
||||
custom_entry.OnMouseIn = on_hover;
|
||||
custom_entry.OnMouseOut = on_hover_stop;
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ func AddItem(symbol, string text, user_ID, proplist target, command, parameter,
|
|||
if (custom_menu_id)
|
||||
{
|
||||
var temp = {child = custom_entry};
|
||||
CustomMenuUpdate(temp, custom_menu_id, this.ID, this);
|
||||
CustomGuiUpdate(temp, custom_menu_id, this.ID, this);
|
||||
}
|
||||
|
||||
return custom_entry;
|
||||
|
|
|
@ -15,11 +15,11 @@ local menu_id;
|
|||
func Construction()
|
||||
{
|
||||
entries = [];
|
||||
this.Style = MENU_VerticalLayout;
|
||||
this.Style = GUI_VerticalLayout;
|
||||
this.Target = this;
|
||||
this.ID = 0xffffff;
|
||||
|
||||
this.OnClose = MenuAction_Call(this, "OnCloseCallback");
|
||||
this.OnClose = GuiAction_Call(this, "OnCloseCallback");
|
||||
}
|
||||
|
||||
func OnCloseCallback()
|
||||
|
@ -31,7 +31,7 @@ func OnCloseCallback()
|
|||
func Close()
|
||||
{
|
||||
if (menu_id)
|
||||
CustomMenuClose(menu_id);
|
||||
CustomGuiClose(menu_id);
|
||||
if (on_close_callback && on_close_callback[0])
|
||||
on_close_callback[0]->Call(on_close_callback[1], on_close_callback[2]);
|
||||
RemoveObject();
|
||||
|
@ -59,12 +59,12 @@ func AddItem(symbol, string text, user_ID, proplist target, command, parameter,
|
|||
{
|
||||
custom_menu_id = custom_menu_id ?? menu_id;
|
||||
|
||||
var on_hover = MenuAction_SetTag(nil, 0, "OnHover");
|
||||
var on_hover = GuiAction_SetTag(nil, 0, "OnHover");
|
||||
if (on_mouse_over_callback)
|
||||
on_hover = [on_hover, MenuAction_Call(this, "DoCallback", on_mouse_over_callback)];
|
||||
var on_hover_stop = MenuAction_SetTag(nil, 0, "Std");
|
||||
on_hover = [on_hover, GuiAction_Call(this, "DoCallback", on_mouse_over_callback)];
|
||||
var on_hover_stop = GuiAction_SetTag(nil, 0, "Std");
|
||||
if (on_mouse_out_callback)
|
||||
on_hover_stop = [on_hover_stop, MenuAction_Call(this, "DoCallback", on_mouse_out_callback)];
|
||||
on_hover_stop = [on_hover_stop, GuiAction_Call(this, "DoCallback", on_mouse_out_callback)];
|
||||
|
||||
var ID = GetLength(entries) + 1;
|
||||
if (!custom_entry)
|
||||
|
@ -72,13 +72,13 @@ func AddItem(symbol, string text, user_ID, proplist target, command, parameter,
|
|||
custom_entry = {Hgt = [0, 64], sym = {Wdt = [0, 64], Hgt = [0, 64]}, desc = {X = [0, 64]}};
|
||||
custom_entry.sym.Symbol = symbol;
|
||||
custom_entry.desc.Text = text;
|
||||
custom_entry.desc.Style = MENU_TextVCenter;
|
||||
custom_entry.Style = MENU_FitChildren;
|
||||
custom_entry.desc.Style = GUI_TextVCenter;
|
||||
custom_entry.Style = GUI_FitChildren;
|
||||
custom_entry.ID = ID;
|
||||
custom_entry.Target = this;
|
||||
custom_entry.Priority = ID;
|
||||
custom_entry.BackgroundColor = {Std = 0, OnHover = 0x50ff0000};
|
||||
custom_entry.OnClick = MenuAction_Call(this, "OnClick");
|
||||
custom_entry.OnClick = GuiAction_Call(this, "OnClick");
|
||||
custom_entry.OnMouseIn = on_hover;
|
||||
custom_entry.OnMouseOut = on_hover_stop;
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ func AddItem(symbol, string text, user_ID, proplist target, command, parameter,
|
|||
if (custom_menu_id)
|
||||
{
|
||||
var temp = {child = custom_entry};
|
||||
CustomMenuUpdate(temp, custom_menu_id, this.ID, this);
|
||||
CustomGuiUpdate(temp, custom_menu_id, this.ID, this);
|
||||
}
|
||||
|
||||
return custom_entry;
|
||||
|
@ -105,7 +105,7 @@ func RemoveItem(user_ID, int custom_menu_id)
|
|||
var ID = i+1;
|
||||
if (!entries[i]) continue;
|
||||
if (entries[i][3] != user_ID) continue;
|
||||
CustomMenuClose(custom_menu_id, ID, this);
|
||||
CustomGuiClose(custom_menu_id, ID, this);
|
||||
entries[i] = nil;
|
||||
return true;
|
||||
}
|
||||
|
@ -139,6 +139,6 @@ func DoCallback(int player, int ID, int subwindowID, object target, data)
|
|||
|
||||
func Open()
|
||||
{
|
||||
menu_id = CustomMenuOpen(this);
|
||||
menu_id = CustomGuiOpen(this);
|
||||
return menu_id;
|
||||
}
|
|
@ -9,17 +9,17 @@ global func CreateCustomMenu(id menuStyle)
|
|||
return menu;
|
||||
}
|
||||
|
||||
global func MenuAction_Call(proplist target, string function, value)
|
||||
global func GuiAction_Call(proplist target, string function, value)
|
||||
{
|
||||
return [MENU_Call, target, function, value];
|
||||
return [GUI_Call, target, function, value];
|
||||
}
|
||||
|
||||
global func MenuAction_SetTag(object target, int subwindow, string tag)
|
||||
global func GuiAction_SetTag(object target, int subwindow, string tag)
|
||||
{
|
||||
return [MENU_SetTag, target, subwindow, tag];
|
||||
return [GUI_SetTag, target, subwindow, tag];
|
||||
}
|
||||
|
||||
global func Menu_AddMargin(proplist submenu, int marginX, int marginY)
|
||||
global func Gui_AddMargin(proplist submenu, int marginX, int marginY)
|
||||
{
|
||||
submenu.X = submenu.X ?? [0, 0];
|
||||
submenu.Y = submenu.Y ?? [0, 0];
|
||||
|
@ -39,7 +39,7 @@ global func Menu_AddMargin(proplist submenu, int marginX, int marginY)
|
|||
return true;
|
||||
}
|
||||
|
||||
global func Menu_AddCloseButton(proplist menu, proplist target, string callback, parameter)
|
||||
global func Gui_AddCloseButton(proplist menu, proplist target, string callback, parameter)
|
||||
{
|
||||
var close_button =
|
||||
{
|
||||
|
@ -48,23 +48,23 @@ global func Menu_AddCloseButton(proplist menu, proplist target, string callback,
|
|||
Wdt = 1000, Hgt = [0, 32],
|
||||
Symbol = Icon_Cancel,
|
||||
BackgroundColor = {Std = 0, Hover = 0x50ffff00},
|
||||
OnMouseIn = MenuAction_SetTag(nil, nil, "Hover"),
|
||||
OnMouseOut = MenuAction_SetTag(nil, nil, "Std"),
|
||||
OnClick = MenuAction_Call(target, callback, parameter)
|
||||
OnMouseIn = GuiAction_SetTag(nil, nil, "Hover"),
|
||||
OnMouseOut = GuiAction_SetTag(nil, nil, "Std"),
|
||||
OnClick = GuiAction_Call(target, callback, parameter)
|
||||
};
|
||||
Menu_AddSubmenu(close_button, menu);
|
||||
Gui_AddSubwindow(close_button, menu);
|
||||
return close_button;
|
||||
}
|
||||
|
||||
global func Menu_UpdateText(string text, int menu, int submenu, object target)
|
||||
global func Gui_UpdateText(string text, int menu, int submenu, object target)
|
||||
{
|
||||
var update = {Text = text};
|
||||
CustomMenuUpdate(update, menu, submenu, target);
|
||||
CustomGuiUpdate(update, menu, submenu, target);
|
||||
return true;
|
||||
}
|
||||
|
||||
// adds proplist /submenu/ as a new property to /menu/
|
||||
global func Menu_AddSubmenu(proplist submenu, proplist menu)
|
||||
global func Gui_AddSubwindow(proplist submenu, proplist menu)
|
||||
{
|
||||
do
|
||||
{
|
||||
|
|
|
@ -4,41 +4,41 @@ func Initialize()
|
|||
{
|
||||
var starter_menu =
|
||||
{
|
||||
Style = MENU_Multiple,
|
||||
Style = GUI_Multiple | GUI_TextVCenter | GUI_TextHCenter,
|
||||
Decoration = GUI_MenuDeco,
|
||||
X = [1000, -100], Y = [0, 50],
|
||||
Wdt = [1000], Hgt = [0, 100],
|
||||
text = {Style = MENU_TextVCenter | MENU_TextHCenter, Text = "OPEN MENU"},
|
||||
Text = "OPEN MENU",
|
||||
BackgroundColor = {Std = 0, Hover = 0xffff0000},
|
||||
OnMouseIn = MenuAction_SetTag(nil, nil, "Hover"),
|
||||
OnMouseOut = MenuAction_SetTag(nil, nil, "Std"),
|
||||
OnClick = MenuAction_Call(Scenario, "StartMenu")
|
||||
OnMouseIn = GuiAction_SetTag(nil, nil, "Hover"),
|
||||
OnMouseOut = GuiAction_SetTag(nil, nil, "Std"),
|
||||
OnClick = GuiAction_Call(Scenario, "StartMenu")
|
||||
};
|
||||
CustomMenuOpen(starter_menu);
|
||||
CustomGuiOpen(starter_menu);
|
||||
}
|
||||
|
||||
func CloseCurrentMenu()
|
||||
{
|
||||
CustomMenuClose(active_menu);
|
||||
CustomGuiClose(active_menu);
|
||||
active_menu = 0;
|
||||
}
|
||||
|
||||
/* -------------------------------- MAIN ----------------------------- */
|
||||
func MainOnHover(parameter, int ID)
|
||||
{
|
||||
Menu_UpdateText(parameter, active_menu, 9999);
|
||||
Gui_UpdateText(parameter, active_menu, 9999);
|
||||
}
|
||||
func StartMenu(plr)
|
||||
{
|
||||
if (active_menu)
|
||||
CustomMenuClose(active_menu);
|
||||
CustomGuiClose(active_menu);
|
||||
var main_menu =
|
||||
{
|
||||
Decoration = GUI_MenuDeco,
|
||||
head = {Hgt = [0, 50], Text = "Please choose a test!", Style = MENU_TextHCenter | MENU_TextVCenter, IDs = 0},
|
||||
body = {Y = [0, 60], right = {X = 500, BackgroundColor = 0x50ffffff } },
|
||||
head = {Hgt = [0, 50], Text = "Please choose a test!", Style = GUI_TextHCenter | GUI_TextVCenter, IDs = 0},
|
||||
body = {Y = [0, 60], right = {ID = 9999, X = 500} },
|
||||
};
|
||||
Menu_AddCloseButton(main_menu, Scenario, "CloseCurrentMenu");
|
||||
Gui_AddCloseButton(main_menu, Scenario, "CloseCurrentMenu");
|
||||
var menu = CreateCustomMenu(MenuStyle_List);
|
||||
main_menu.body.left = menu;
|
||||
|
||||
|
@ -48,24 +48,25 @@ func StartMenu(plr)
|
|||
menu->AddItem(Rule_TeamAccount, "Test Client/Host (Scenario Options)", nil, Scenario, "StartScenarioOptionsTest", "Shows how to display a dialogue that behaves differently for players.");
|
||||
menu->AddItem(Clonk, "Test Multiple Windows (Player List)", nil, Scenario, "StartPlayerListTest", "Shows how to display a permanent info dialogue.");
|
||||
menu->AddItem(Lorry, "Tests Two Grid Menus (Trade Menu)", nil, Scenario, "StartTransferTest", "Shows how to work with two grid menus.");
|
||||
menu->AddItem(Sproutberry, "Test HP Bars (HP Bars!)", nil, Scenario, "StartHPBarTest", "HP BARS!!!");
|
||||
|
||||
active_menu = CustomMenuOpen(main_menu);
|
||||
active_menu = CustomGuiOpen(main_menu);
|
||||
}
|
||||
|
||||
/* ------------------------ inventory test ----------------------------- */
|
||||
static selected_inventory, inv_menus;
|
||||
func StartMultipleListTest()
|
||||
{
|
||||
CustomMenuClose(active_menu);
|
||||
CustomGuiClose(active_menu);
|
||||
selected_inventory = [];
|
||||
inv_menus = [];
|
||||
// layout: headline and four sections with items
|
||||
var menu =
|
||||
{
|
||||
head = { ID = 999, Hgt = [0, 50], Text = "Inventory: <c ff0000>Empty</c>", Style = MENU_TextHCenter | MENU_TextVCenter, BackgroundColor = 0x55000000},
|
||||
head = { ID = 999, Hgt = [0, 50], Text = "Inventory: <c ff0000>Empty</c>", Style = GUI_TextHCenter | GUI_TextVCenter, BackgroundColor = 0x55000000},
|
||||
contents = { Y = [0, 50], X = [0, 20], Wdt = [1000, -20] },
|
||||
};
|
||||
Menu_AddCloseButton(menu, Scenario, "CloseCurrentMenu");
|
||||
Gui_AddCloseButton(menu, Scenario, "CloseCurrentMenu");
|
||||
|
||||
var inventory = [[Sword, Axe, Club], [IronBomb, Dynamite, Boompack, Firestone], [Bow, Musket, Javelin], [Shield, Bread, Sproutberry, CookedMushroom]];
|
||||
var x = [0, [500, 20], 0, [500, 20]], y = [0, 0, [500, 20], [500, 20]], w = [[500, -20], 1000, [500, -20], 1000], h = [[500, -20], [500, -20], 1000, 1000];
|
||||
|
@ -77,12 +78,12 @@ func StartMultipleListTest()
|
|||
m.Decoration = GUI_MenuDeco;
|
||||
m.X = x[i]; m.Y = y[i];
|
||||
m.Wdt = w[i]; m.Hgt = h[i];
|
||||
Menu_AddSubmenu(m, menu.contents);
|
||||
Gui_AddSubwindow(m, menu.contents);
|
||||
PushBack(inv_menus, m); // remember for later
|
||||
for (var obj in inv)
|
||||
m->AddItem(obj, obj.Description, nil, Scenario, "SelectInventory", [obj, ID]);
|
||||
}
|
||||
active_menu = CustomMenuOpen(menu);
|
||||
active_menu = CustomGuiOpen(menu);
|
||||
}
|
||||
|
||||
func SelectInventory(info)
|
||||
|
@ -98,12 +99,12 @@ func SelectInventory(info)
|
|||
Log("HERO! YOU WILL SPAWN NOW! %s", text);
|
||||
for (var m in inv_menus)
|
||||
if (m) m->Close();
|
||||
CustomMenuClose(active_menu);
|
||||
CustomGuiClose(active_menu);
|
||||
}
|
||||
else
|
||||
{
|
||||
var update = { Text = text };
|
||||
CustomMenuUpdate(update, active_menu, 999);
|
||||
CustomGuiUpdate(update, active_menu, 999);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -111,7 +112,7 @@ func SelectInventory(info)
|
|||
static scenoptions_dummies;
|
||||
func StartScenarioOptionsTest(parameter, int ID, int player)
|
||||
{
|
||||
CustomMenuClose(active_menu);
|
||||
CustomGuiClose(active_menu);
|
||||
scenoptions_dummies = [];
|
||||
scenoptions_dummies[0] = CreateObject(Dummy, nil, nil, player);
|
||||
scenoptions_dummies[1] = CreateObject(Dummy, nil, nil, player);
|
||||
|
@ -140,7 +141,7 @@ func StartScenarioOptionsTest(parameter, int ID, int player)
|
|||
list =
|
||||
{
|
||||
Wdt = 500,
|
||||
Style = MENU_VerticalLayout,
|
||||
Style = GUI_VerticalLayout,
|
||||
},
|
||||
right = {
|
||||
X = 500,
|
||||
|
@ -160,9 +161,9 @@ func StartScenarioOptionsTest(parameter, int ID, int player)
|
|||
}
|
||||
}
|
||||
};
|
||||
Menu_AddMargin(menu.right.hostdesc, 25, 25);
|
||||
Menu_AddMargin(menu.right.clientdesc, 25, 25);
|
||||
Menu_AddCloseButton(menu, Scenario, "CloseCurrentMenu");
|
||||
Gui_AddMargin(menu.right.hostdesc, 25, 25);
|
||||
Gui_AddMargin(menu.right.clientdesc, 25, 25);
|
||||
Gui_AddCloseButton(menu, Scenario, "CloseCurrentMenu");
|
||||
|
||||
var def, rules =[], i = 0;
|
||||
while (def = GetDefinition(i++))
|
||||
|
@ -177,7 +178,7 @@ func StartScenarioOptionsTest(parameter, int ID, int player)
|
|||
ID = rule.ID,
|
||||
Hgt = [0, 64],
|
||||
icon = {Priority = 10, Symbol = rule.def, Wdt = [0, 64], Hgt = [0, 64]},
|
||||
text = {Priority = 10, X = [0, 64], Style = MENU_TextVCenter, Text = rule.def.Name},
|
||||
text = {Priority = 10, X = [0, 64], Style = GUI_TextVCenter, Text = rule.def.Name},
|
||||
|
||||
selector = // only visible for host
|
||||
{
|
||||
|
@ -185,13 +186,13 @@ func StartScenarioOptionsTest(parameter, int ID, int player)
|
|||
Priority = 1,
|
||||
BackgroundColor = {Std = 0, Hover = 0x50ff0000, On = 0x2000ff00},
|
||||
OnMouseIn = {
|
||||
Std = [MenuAction_Call(Scenario, "ScenOptsUpdateDesc", [rule.def, rule.ID, false]), MenuAction_SetTag(nil, nil, "Hover")],
|
||||
On = MenuAction_Call(Scenario, "ScenOptsUpdateDesc", [rule.def, rule.ID, true])
|
||||
Std = [GuiAction_Call(Scenario, "ScenOptsUpdateDesc", [rule.def, rule.ID, false]), GuiAction_SetTag(nil, nil, "Hover")],
|
||||
On = GuiAction_Call(Scenario, "ScenOptsUpdateDesc", [rule.def, rule.ID, true])
|
||||
},
|
||||
OnMouseOut = { Hover = MenuAction_SetTag(nil, nil, "Std"), On = nil },
|
||||
OnMouseOut = { Hover = GuiAction_SetTag(nil, nil, "Std"), On = nil },
|
||||
OnClick = {
|
||||
Hover = [MenuAction_Call(Scenario, "ScenOptsActivate", [rule.def, rule.ID]), MenuAction_SetTag(nil, nil, "On")],
|
||||
On = [MenuAction_Call(Scenario, "ScenOptsDeactivate", [rule.def, rule.ID]), MenuAction_SetTag(nil, nil, "Hover")],
|
||||
Hover = [GuiAction_Call(Scenario, "ScenOptsActivate", [rule.def, rule.ID]), GuiAction_SetTag(nil, nil, "On")],
|
||||
On = [GuiAction_Call(Scenario, "ScenOptsDeactivate", [rule.def, rule.ID]), GuiAction_SetTag(nil, nil, "Hover")],
|
||||
},
|
||||
},
|
||||
tick =
|
||||
|
@ -201,23 +202,23 @@ func StartScenarioOptionsTest(parameter, int ID, int player)
|
|||
Symbol = {Std = 0, Unticked = 0, Ticked = Icon_Ok}
|
||||
}
|
||||
};
|
||||
Menu_AddSubmenu(subm, menu.list);
|
||||
Gui_AddSubwindow(subm, menu.list);
|
||||
}
|
||||
|
||||
active_menu = CustomMenuOpen(menu);
|
||||
active_menu = CustomGuiOpen(menu);
|
||||
}
|
||||
|
||||
func ScenOptsActivate(int player, int ID, int subwindowID, object target, data)
|
||||
{
|
||||
if (!ObjectCount(Find_ID(data[0])))
|
||||
CreateObject(data[0]);
|
||||
CustomMenuSetTag("Ticked", active_menu, data[1], nil);
|
||||
CustomGuiSetTag("Ticked", active_menu, data[1], nil);
|
||||
}
|
||||
|
||||
func ScenOptsDeactivate(int player, int ID, int subwindowID, object target, data)
|
||||
{
|
||||
RemoveAll(Find_ID(data[0]));
|
||||
CustomMenuSetTag("Unticked", active_menu, data[1], nil);
|
||||
CustomGuiSetTag("Unticked", active_menu, data[1], nil);
|
||||
}
|
||||
|
||||
func ScenOptsUpdateDesc(int player, int ID, int subwindowID, object target, data)
|
||||
|
@ -225,7 +226,7 @@ func ScenOptsUpdateDesc(int player, int ID, int subwindowID, object target, data
|
|||
var text = "<c ff0000>Do you really want to remove the rule???</c>";
|
||||
if (!data[2])
|
||||
text = data[0].Description;
|
||||
Menu_UpdateText(text, active_menu, 1, scenoptions_dummies[0]);
|
||||
Gui_UpdateText(text, active_menu, 1, scenoptions_dummies[0]);
|
||||
}
|
||||
|
||||
/* ------------------------ player list test ----------------------------- */
|
||||
|
@ -234,7 +235,7 @@ func StartPlayerListTest(parameter, int ID, int player)
|
|||
{
|
||||
if (player_list_menu)
|
||||
{
|
||||
CustomMenuClose(player_list_menu);
|
||||
CustomGuiClose(player_list_menu);
|
||||
player_list_menu = nil;
|
||||
return -1;
|
||||
}
|
||||
|
@ -243,7 +244,7 @@ func StartPlayerListTest(parameter, int ID, int player)
|
|||
{
|
||||
X = [1000, -150], Y = [0, 100],
|
||||
Wdt = [1000, -5], Hgt = [0, 200],
|
||||
Style = MENU_Multiple | MENU_VerticalLayout | MENU_FitChildren,
|
||||
Style = GUI_Multiple | GUI_VerticalLayout | GUI_FitChildren,
|
||||
BackgroundColor = 0x30000000,
|
||||
};
|
||||
|
||||
|
@ -259,17 +260,17 @@ func StartPlayerListTest(parameter, int ID, int player)
|
|||
Priority = i,
|
||||
Hgt = [0, 25],
|
||||
Text = name,
|
||||
Style = MENU_TextRight | MENU_TextVCenter,
|
||||
Style = GUI_TextRight | GUI_TextVCenter,
|
||||
icon =
|
||||
{
|
||||
Symbol = Clonk,
|
||||
Wdt = [0, 25]
|
||||
}
|
||||
};
|
||||
Menu_AddSubmenu(subm, menu);
|
||||
Gui_AddSubwindow(subm, menu);
|
||||
}
|
||||
|
||||
player_list_menu = CustomMenuOpen(menu);
|
||||
player_list_menu = CustomGuiOpen(menu);
|
||||
|
||||
return -1; // keep open
|
||||
}
|
||||
|
@ -278,7 +279,7 @@ func StartPlayerListTest(parameter, int ID, int player)
|
|||
static transfer_left, transfer_right, transfer_menus, transfer_id_count;
|
||||
func StartTransferTest()
|
||||
{
|
||||
CustomMenuClose(active_menu);
|
||||
CustomGuiClose(active_menu);
|
||||
if (transfer_left == nil)
|
||||
{
|
||||
transfer_left = [Rock, Loam, Wood, Metal, Nugget, Coal, Shovel, Sword, Bow, Arrow, Boompack];
|
||||
|
@ -290,23 +291,23 @@ func StartTransferTest()
|
|||
// layout: headline and two submenus
|
||||
var menu =
|
||||
{
|
||||
head = { Hgt = [0, 50], Text = "Welcome to the trade menu!", Style = MENU_TextHCenter | MENU_TextVCenter, BackgroundColor = 0x55000000},
|
||||
contents = { Y = [0, 50], X = [0, 20], Wdt = [1000, -20] },
|
||||
head = { Hgt = [0, 50], Text = "Welcome to the trade menu!", Style = GUI_TextHCenter | GUI_TextVCenter},
|
||||
contents = { Y = [0, 25], X = [0, 20], Wdt = [1000, -20] },
|
||||
};
|
||||
Menu_AddCloseButton(menu, Scenario, "CloseCurrentMenu");
|
||||
Gui_AddCloseButton(menu, Scenario, "CloseCurrentMenu");
|
||||
|
||||
for (var i = 0; i < 2; ++i)
|
||||
{
|
||||
var m = CreateCustomMenu(MenuStyle_Grid);
|
||||
m.Decoration = GUI_MenuDeco;
|
||||
m.Text = "FROM";
|
||||
m.Style = MENU_TextHCenter;
|
||||
m.Style = GUI_TextHCenter | GUI_GridLayout;
|
||||
if (i == 1)
|
||||
{
|
||||
m.X = 500;
|
||||
m.X = [500, 15];
|
||||
m.Text = "TO";
|
||||
} else m.Wdt = 500;
|
||||
Menu_AddSubmenu(m, menu.contents);
|
||||
} else m.Wdt = [500, -15];
|
||||
Gui_AddSubwindow(m, menu.contents);
|
||||
var a = transfer_left;
|
||||
if (i == 1) a = transfer_right;
|
||||
|
||||
|
@ -317,7 +318,7 @@ func StartTransferTest()
|
|||
}
|
||||
transfer_menus[i] = m;
|
||||
}
|
||||
active_menu = CustomMenuOpen(menu);
|
||||
active_menu = CustomGuiOpen(menu);
|
||||
}
|
||||
|
||||
func SelectTransferGood(data, int user_id, int player)
|
||||
|
@ -346,4 +347,45 @@ func SelectTransferGood(data, int user_id, int player)
|
|||
if (!menu->RemoveItem(user_id, active_menu)) Log("remove fail!");
|
||||
transfer_menus[1 - data[1]]->AddItem(obj, obj.Name, user_id, Scenario, "SelectTransferGood", [obj, 1 - data[1]], nil, active_menu);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------ HP bar test ----------------------------- */
|
||||
static HP_bar_menu;
|
||||
func StartHPBarTest(parameter, int ID, int player)
|
||||
{
|
||||
if (HP_bar_menu)
|
||||
{
|
||||
CustomGuiClose(HP_bar_menu);
|
||||
return -1; // keep open
|
||||
}
|
||||
|
||||
var menu =
|
||||
{
|
||||
X = [0, 10], Y = [0, 50],
|
||||
Wdt = [0, 15], Hgt = [1000, -50],
|
||||
Style = GUI_Multiple | GUI_IgnoreMouse,
|
||||
BackgroundColor = RGB(255, 0, 0),
|
||||
blackOverlay = {ID = 1, Hgt = 0, BackgroundColor = RGB(10, 10, 10)},
|
||||
OnClose = GuiAction_Call(Scenario, "OnHPBarClose")
|
||||
};
|
||||
if (!GetEffect("FoolAroundWithHPBars"))
|
||||
AddEffect("FoolAroundWithHPBar", nil, 1, 2);
|
||||
HP_bar_menu = CustomGuiOpen(menu);
|
||||
|
||||
return -1; // keep open
|
||||
}
|
||||
|
||||
global func FxFoolAroundWithHPBarTimer(target, effect, time)
|
||||
{
|
||||
var state = Abs(Cos(time, 1000));
|
||||
var update = {Hgt = state};
|
||||
CustomGuiUpdate(update, HP_bar_menu, 1);
|
||||
}
|
||||
|
||||
func OnHPBarClose()
|
||||
{
|
||||
RemoveEffect("FoolAroundWithHPBar");
|
||||
HP_bar_menu = nil;
|
||||
Log("HP bar off!");
|
||||
}
|
|
@ -49,7 +49,7 @@
|
|||
#include <C4PlayerList.h>
|
||||
#include <C4GameObjects.h>
|
||||
#include <C4GameControl.h>
|
||||
#include <C4MenuWindow.h>
|
||||
#include <C4GuiWindow.h>
|
||||
|
||||
#ifndef NOAULDEBUG
|
||||
#include <C4AulDebug.h>
|
||||
|
@ -430,13 +430,13 @@ C4ControlMenuCommand::C4ControlMenuCommand(int32_t actionID, int32_t player, int
|
|||
void C4ControlMenuCommand::Execute() const
|
||||
{
|
||||
// invalid action? The action needs to be in bounds!
|
||||
if (actionType < 0 || actionType >= C4MenuWindowPropertyName::_lastProp)
|
||||
if (actionType < 0 || actionType >= C4GuiWindowPropertyName::_lastProp)
|
||||
{
|
||||
// this could only come from a malicious attempt to crash the engine!
|
||||
Log("Warning: invalid action type for C4ControlMenuCommand!");
|
||||
return;
|
||||
}
|
||||
C4MenuWindow *menu = ::MenuWindowRoot.GetChildByID(menuID);
|
||||
C4GuiWindow *menu = ::GuiWindowRoot.GetChildByID(menuID);
|
||||
// menu was closed?
|
||||
if (!menu) return;
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@
|
|||
#include <C4RankSystem.h>
|
||||
#include <C4RoundResults.h>
|
||||
#include <C4GameMessage.h>
|
||||
#include <C4MenuWindow.h>
|
||||
#include <C4GuiWindow.h>
|
||||
#include <C4Material.h>
|
||||
#include <C4Network2Reference.h>
|
||||
#include <C4Weather.h>
|
||||
|
@ -920,7 +920,7 @@ void C4Game::ClearPointers(C4Object * pObj)
|
|||
::MessageInput.ClearPointers(pObj);
|
||||
::Console.ClearPointers(pObj);
|
||||
::MouseControl.ClearPointers(pObj);
|
||||
::MenuWindowRoot.ClearPointers(pObj);
|
||||
::GuiWindowRoot.ClearPointers(pObj);
|
||||
TransferZones.ClearPointers(pObj);
|
||||
if (pGlobalEffects)
|
||||
pGlobalEffects->ClearPointers(pObj);
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
#include <C4MouseControl.h>
|
||||
#include <C4PXS.h>
|
||||
#include <C4GameMessage.h>
|
||||
#include <C4MenuWindow.h>
|
||||
#include <C4GuiWindow.h>
|
||||
#include <C4GraphicsResource.h>
|
||||
#include <C4GraphicsSystem.h>
|
||||
#include <C4Landscape.h>
|
||||
|
@ -303,10 +303,10 @@ void C4Viewport::Draw(C4TargetFacet &cgo0, bool fDrawOverlay)
|
|||
C4ST_STOP(MsgStat)
|
||||
|
||||
// ingame menus
|
||||
C4ST_STARTNEW(MenuWindowStat, "C4Viewport::DrawOverlay: Menus")
|
||||
C4ST_STARTNEW(GuiWindowStat, "C4Viewport::DrawOverlay: Menus")
|
||||
pDraw->SetZoom(0, 0, 1.0);
|
||||
::MenuWindowRoot.Draw(gui_cgo, Player);
|
||||
C4ST_STOP(MenuWindowStat)
|
||||
::GuiWindowRoot.Draw(gui_cgo, Player);
|
||||
C4ST_STOP(GuiWindowStat)
|
||||
|
||||
DrawOverlay(gui_cgo, GameZoom);
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
#include <C4GraphicsSystem.h>
|
||||
#include <C4Log.h>
|
||||
#include <C4MessageInput.h>
|
||||
#include <C4MenuWindow.h>
|
||||
#include <C4GuiWindow.h>
|
||||
#include <C4MouseControl.h>
|
||||
#include <C4ObjectInfoList.h>
|
||||
#include <C4Player.h>
|
||||
|
@ -2130,28 +2130,28 @@ static bool FnCustomMessage(C4PropList * _this, C4String *pMsg, C4Object *pObj,
|
|||
return ::Messages.New(iType,sMsg,pObj,iOwner,iOffX,iOffY,(uint32_t)dwClr, idDeco, pSrc, dwFlags, iHSize);
|
||||
}
|
||||
|
||||
static int FnCustomMenuOpen(C4PropList * _this, C4PropList *menu)
|
||||
static int FnCustomGuiOpen(C4PropList * _this, C4PropList *menu)
|
||||
{
|
||||
C4MenuWindow *window = new C4MenuWindow;
|
||||
C4GuiWindow *window = new C4GuiWindow;
|
||||
|
||||
::MenuWindowRoot.AddChild(window);
|
||||
::GuiWindowRoot.AddChild(window);
|
||||
|
||||
if (!window->CreateFromPropList(menu, true))
|
||||
{
|
||||
::MenuWindowRoot.RemoveChild(window, false);
|
||||
::GuiWindowRoot.RemoveChild(window, false);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return window->GetID();
|
||||
}
|
||||
|
||||
static bool FnCustomMenuSetTag(C4PropList * _this, C4String *tag, int32_t menuID, int32_t childID, C4Object *target)
|
||||
static bool FnCustomGuiSetTag(C4PropList * _this, C4String *tag, int32_t menuID, int32_t childID, C4Object *target)
|
||||
{
|
||||
C4MenuWindow *window = ::MenuWindowRoot.GetChildByID(menuID);
|
||||
C4GuiWindow *window = ::GuiWindowRoot.GetChildByID(menuID);
|
||||
if (!window) return false;
|
||||
if (childID) // note: valid child IDs are always non-zero
|
||||
{
|
||||
C4MenuWindow *subwindow = window->GetSubWindow(childID, target);
|
||||
C4GuiWindow *subwindow = window->GetSubWindow(childID, target);
|
||||
if (!subwindow) return false;
|
||||
subwindow->SetTag(tag);
|
||||
return true;
|
||||
|
@ -2160,13 +2160,13 @@ static bool FnCustomMenuSetTag(C4PropList * _this, C4String *tag, int32_t menuID
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool FnCustomMenuClose(C4PropList *_this, int32_t menuID, int32_t childID, C4Object *target)
|
||||
static bool FnCustomGuiClose(C4PropList *_this, int32_t menuID, int32_t childID, C4Object *target)
|
||||
{
|
||||
C4MenuWindow *window = ::MenuWindowRoot.GetChildByID(menuID);
|
||||
C4GuiWindow *window = ::GuiWindowRoot.GetChildByID(menuID);
|
||||
if (!window) return false;
|
||||
if (childID) // note: valid child IDs are always non-zero
|
||||
{
|
||||
C4MenuWindow *subwindow = window->GetSubWindow(childID, target);
|
||||
C4GuiWindow *subwindow = window->GetSubWindow(childID, target);
|
||||
if (!subwindow) return false;
|
||||
subwindow->Close();
|
||||
return true;
|
||||
|
@ -2175,14 +2175,14 @@ static bool FnCustomMenuClose(C4PropList *_this, int32_t menuID, int32_t childID
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool FxCustomMenuUpdate(C4PropList *_this, C4PropList *update, int32_t menuID, int32_t childID, C4Object *target)
|
||||
static bool FxCustomGuiUpdate(C4PropList *_this, C4PropList *update, int32_t menuID, int32_t childID, C4Object *target)
|
||||
{
|
||||
if (!update) return false;
|
||||
C4MenuWindow *window = ::MenuWindowRoot.GetChildByID(menuID);
|
||||
C4GuiWindow *window = ::GuiWindowRoot.GetChildByID(menuID);
|
||||
if (!window) return false;
|
||||
if (childID) // note: valid child IDs are always non-zero
|
||||
{
|
||||
C4MenuWindow *subwindow = window->GetSubWindow(childID, target);
|
||||
C4GuiWindow *subwindow = window->GetSubWindow(childID, target);
|
||||
if (!subwindow) return false;
|
||||
subwindow->CreateFromPropList(update, false, true);
|
||||
return true;
|
||||
|
@ -2485,10 +2485,10 @@ void InitGameFunctionMap(C4AulScriptEngine *pEngine)
|
|||
AddFunc(pEngine, "ExtractMaterialAmount", FnExtractMaterialAmount);
|
||||
AddFunc(pEngine, "GetEffectCount", FnGetEffectCount);
|
||||
AddFunc(pEngine, "CustomMessage", FnCustomMessage);
|
||||
AddFunc(pEngine, "CustomMenuOpen", FnCustomMenuOpen);
|
||||
AddFunc(pEngine, "CustomMenuSetTag", FnCustomMenuSetTag);
|
||||
AddFunc(pEngine, "CustomMenuClose", FnCustomMenuClose);
|
||||
AddFunc(pEngine, "CustomMenuUpdate", FxCustomMenuUpdate);
|
||||
AddFunc(pEngine, "CustomGuiOpen", FnCustomGuiOpen);
|
||||
AddFunc(pEngine, "CustomGuiSetTag", FnCustomGuiSetTag);
|
||||
AddFunc(pEngine, "CustomGuiClose", FnCustomGuiClose);
|
||||
AddFunc(pEngine, "CustomGuiUpdate", FxCustomGuiUpdate);
|
||||
AddFunc(pEngine, "PauseGame", FnPauseGame, false);
|
||||
AddFunc(pEngine, "PathFree", FnPathFree);
|
||||
AddFunc(pEngine, "PathFree2", FnPathFree2);
|
||||
|
@ -2643,18 +2643,19 @@ C4ScriptConstDef C4ScriptGameConstMap[]=
|
|||
{ "PLRZOOM_LimitMin" ,C4V_Int, PLRZOOM_LimitMin },
|
||||
{ "PLRZOOM_LimitMax" ,C4V_Int, PLRZOOM_LimitMax },
|
||||
|
||||
{ "MENU_SetTag" ,C4V_Int, C4MenuWindowActionID::SetTag },
|
||||
{ "MENU_Call" ,C4V_Int, C4MenuWindowActionID::Call },
|
||||
{ "MENU_GridLayout" ,C4V_Int, C4MenuWindowStyleFlag::GridLayout },
|
||||
{ "MENU_VerticalLayout" ,C4V_Int, C4MenuWindowStyleFlag::VerticalLayout },
|
||||
{ "MENU_TextVCenter" ,C4V_Int, C4MenuWindowStyleFlag::TextVCenter },
|
||||
{ "MENU_TextHCenter" ,C4V_Int, C4MenuWindowStyleFlag::TextHCenter },
|
||||
{ "MENU_TextRight" ,C4V_Int, C4MenuWindowStyleFlag::TextRight },
|
||||
{ "MENU_TextBottom" ,C4V_Int, C4MenuWindowStyleFlag::TextBottom },
|
||||
{ "MENU_TextTop" ,C4V_Int, C4MenuWindowStyleFlag::None }, // note that top and left are considered default
|
||||
{ "MENU_TextLeft" ,C4V_Int, C4MenuWindowStyleFlag::None }, // they are only included for completeness
|
||||
{ "MENU_FitChildren" ,C4V_Int, C4MenuWindowStyleFlag::FitChildren },
|
||||
{ "MENU_Multiple" ,C4V_Int, C4MenuWindowStyleFlag::Multiple },
|
||||
{ "GUI_SetTag" ,C4V_Int, C4GuiWindowActionID::SetTag },
|
||||
{ "GUI_Call" ,C4V_Int, C4GuiWindowActionID::Call },
|
||||
{ "GUI_GridLayout" ,C4V_Int, C4GuiWindowStyleFlag::GridLayout },
|
||||
{ "GUI_VerticalLayout" ,C4V_Int, C4GuiWindowStyleFlag::VerticalLayout },
|
||||
{ "GUI_TextVCenter" ,C4V_Int, C4GuiWindowStyleFlag::TextVCenter },
|
||||
{ "GUI_TextHCenter" ,C4V_Int, C4GuiWindowStyleFlag::TextHCenter },
|
||||
{ "GUI_TextRight" ,C4V_Int, C4GuiWindowStyleFlag::TextRight },
|
||||
{ "GUI_TextBottom" ,C4V_Int, C4GuiWindowStyleFlag::TextBottom },
|
||||
{ "GUI_TextTop" ,C4V_Int, C4GuiWindowStyleFlag::None }, // note that top and left are considered default
|
||||
{ "GUI_TextLeft" ,C4V_Int, C4GuiWindowStyleFlag::None }, // they are only included for completeness
|
||||
{ "GUI_FitChildren" ,C4V_Int, C4GuiWindowStyleFlag::FitChildren },
|
||||
{ "GUI_Multiple" ,C4V_Int, C4GuiWindowStyleFlag::Multiple },
|
||||
{ "GUI_IgnoreMouse" ,C4V_Int, C4GuiWindowStyleFlag::IgnoreMouse },
|
||||
{ NULL, C4V_Nil, 0}
|
||||
};
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -17,8 +17,8 @@
|
|||
|
||||
/* a flexisble ingame menu system that can be composed out of multiple windows */
|
||||
|
||||
#ifndef INC_C4MenuWindow
|
||||
#define INC_C4MenuWindow
|
||||
#ifndef INC_C4GuiWindow
|
||||
#define INC_C4GuiWindow
|
||||
|
||||
#include <C4Surface.h>
|
||||
#include <C4Gui.h>
|
||||
|
@ -27,7 +27,7 @@
|
|||
|
||||
#include <map>
|
||||
|
||||
enum C4MenuWindowPropertyName
|
||||
enum C4GuiWindowPropertyName
|
||||
{
|
||||
left = 0,
|
||||
top,
|
||||
|
@ -51,13 +51,13 @@ enum C4MenuWindowPropertyName
|
|||
_lastProp
|
||||
};
|
||||
|
||||
enum C4MenuWindowActionID
|
||||
enum C4GuiWindowActionID
|
||||
{
|
||||
SetTag = 1,
|
||||
Call,
|
||||
};
|
||||
|
||||
enum C4MenuWindowStyleFlag
|
||||
enum C4GuiWindowStyleFlag
|
||||
{
|
||||
None = 0,
|
||||
GridLayout = 1,
|
||||
|
@ -68,20 +68,21 @@ enum C4MenuWindowStyleFlag
|
|||
TextBottom = 32,
|
||||
FitChildren = 64,
|
||||
Multiple = 128,
|
||||
IgnoreMouse = 256,
|
||||
};
|
||||
|
||||
class C4MenuWindow;
|
||||
class C4GuiWindow;
|
||||
|
||||
class C4MenuWindowAction
|
||||
class C4GuiWindowAction
|
||||
{
|
||||
friend class C4MenuWindow;
|
||||
friend class C4GuiWindow;
|
||||
|
||||
private:
|
||||
// the ID is unique among all actions. It is used later to synchronize callbacks
|
||||
int32_t id;
|
||||
|
||||
int32_t action;
|
||||
C4MenuWindowAction *nextAction; // a linked list of actions
|
||||
C4GuiWindowAction *nextAction; // a linked list of actions
|
||||
// note: depending on the action not all of the following attributes always have values
|
||||
C4PropList *target; // contains a valid C4Object in case of SetTag, a generic proplist in case of Call
|
||||
C4String *text; // can be either a function name to call or a tag to set
|
||||
|
@ -89,20 +90,20 @@ class C4MenuWindowAction
|
|||
int32_t subwindowID;
|
||||
|
||||
public:
|
||||
C4MenuWindowAction() : id(0), action(0), nextAction(0), target(0), text(0), value(0), subwindowID(0) { }
|
||||
~C4MenuWindowAction();
|
||||
C4GuiWindowAction() : id(0), action(0), nextAction(0), target(0), text(0), value(0), subwindowID(0) { }
|
||||
~C4GuiWindowAction();
|
||||
void ClearPointers(C4Object *pObj);
|
||||
bool Init(C4ValueArray *array, int32_t index = 0); // index is the current action in an array of actions
|
||||
// executes non-synced actions and syncs the others
|
||||
// the tag and action type parameters are only used to be able to sync commands
|
||||
void Execute(C4MenuWindow *parent, int32_t player, unsigned int tag, int32_t actionType);
|
||||
// used to execute synced commands, explanation see C4MenuWindow::ExecuteCommand
|
||||
bool ExecuteCommand(int32_t actionID, C4MenuWindow *parent, int32_t player);
|
||||
void Execute(C4GuiWindow *parent, int32_t player, unsigned int tag, int32_t actionType);
|
||||
// used to execute synced commands, explanation see C4GuiWindow::ExecuteCommand
|
||||
bool ExecuteCommand(int32_t actionID, C4GuiWindow *parent, int32_t player);
|
||||
};
|
||||
|
||||
class C4MenuWindowProperty
|
||||
class C4GuiWindowProperty
|
||||
{
|
||||
friend class C4MenuWindow;
|
||||
friend class C4GuiWindow;
|
||||
|
||||
private:
|
||||
typedef union
|
||||
|
@ -114,7 +115,7 @@ class C4MenuWindowProperty
|
|||
C4Def *def;
|
||||
C4GUI::FrameDecoration *deco;
|
||||
StdCopyStrBuf *strBuf;
|
||||
C4MenuWindowAction *action;
|
||||
C4GuiWindowAction *action;
|
||||
} Prop;
|
||||
|
||||
Prop *current;
|
||||
|
@ -132,8 +133,8 @@ class C4MenuWindowProperty
|
|||
void SetNull(unsigned int hash) { taggedProperties[hash] = Prop(); current = &taggedProperties[hash]; current->data = 0; }
|
||||
|
||||
public:
|
||||
~C4MenuWindowProperty();
|
||||
C4MenuWindowProperty() : current(0), currentTag(0), type(-1) {}
|
||||
~C4GuiWindowProperty();
|
||||
C4GuiWindowProperty() : current(0), currentTag(0), type(-1) {}
|
||||
void Set(const C4Value &value, unsigned int hash);
|
||||
|
||||
int32_t GetInt() { return current->d; }
|
||||
|
@ -142,8 +143,8 @@ class C4MenuWindowProperty
|
|||
C4Def *GetDef() { return current->def; }
|
||||
C4GUI::FrameDecoration *GetFrameDecoration() { return current->deco; }
|
||||
StdCopyStrBuf *GetStrBuf() { return current->strBuf; }
|
||||
C4MenuWindowAction *GetAction() { return current->action; }
|
||||
C4MenuWindowAction *GetActionForTag(unsigned int hash); // used to synchronize actions
|
||||
C4GuiWindowAction *GetAction() { return current->action; }
|
||||
C4GuiWindowAction *GetActionForTag(unsigned int hash); // used to synchronize actions
|
||||
|
||||
bool SwitchTag(C4String *tag);
|
||||
unsigned int GetCurrentTag() { return currentTag; }
|
||||
|
@ -151,26 +152,26 @@ class C4MenuWindowProperty
|
|||
void ClearPointers(C4Object *pObj);
|
||||
};
|
||||
|
||||
class C4MenuWindowScrollBar
|
||||
class C4GuiWindowScrollBar
|
||||
{
|
||||
friend class C4MenuWindow;
|
||||
friend class C4GuiWindow;
|
||||
|
||||
public:
|
||||
float offset;
|
||||
C4MenuWindowScrollBar();
|
||||
virtual ~C4MenuWindowScrollBar();
|
||||
C4GuiWindowScrollBar();
|
||||
virtual ~C4GuiWindowScrollBar();
|
||||
void ScrollBy(float val) { offset += val; if (offset < 0.0f) offset = 0.0f; else if (offset > 1.0f) offset = 1.0f; }
|
||||
void Draw(C4TargetFacet &cgo, int32_t player, float parentLeft, float parentTop, float parentRight, float parentBottom);
|
||||
virtual bool MouseInput(int32_t button, int32_t mouseX, int32_t mouseY, DWORD dwKeyParam);
|
||||
|
||||
private:
|
||||
C4GUI::ScrollBarFacets *decoration;
|
||||
C4MenuWindow *parent;
|
||||
C4GuiWindow *parent;
|
||||
};
|
||||
|
||||
class C4MenuWindow
|
||||
class C4GuiWindow
|
||||
{
|
||||
friend class C4MenuWindowAction;
|
||||
friend class C4GuiWindowAction;
|
||||
|
||||
private:
|
||||
// the menu ID is always unique, however the sub-menu IDs do NOT have to be unique
|
||||
|
@ -180,14 +181,14 @@ class C4MenuWindow
|
|||
// this does not mean the ::WindowMenuRoot but rather a player-created submenu
|
||||
bool isMainWindow;
|
||||
|
||||
std::list<C4MenuWindow*> children;
|
||||
C4MenuWindow *parent;
|
||||
std::list<C4GuiWindow*> children;
|
||||
C4GuiWindow *parent;
|
||||
bool wasRemoved; // to notify the window that it should not inform its parent on Close() a second time
|
||||
|
||||
bool closeActionWasExecuted; // to prevent a window from calling the close-callback twice even if f.e. closed in the close-callback..
|
||||
bool visible;
|
||||
C4Object *target;
|
||||
const C4Object *GetTarget() { return target; }
|
||||
C4MenuWindowScrollBar *scrollBar;
|
||||
C4GuiWindowScrollBar *scrollBar;
|
||||
|
||||
// this remembers whether the window currently has mouse focus
|
||||
// all windows with this property set are remembered by their parents and notified when the mouse left
|
||||
|
@ -198,7 +199,7 @@ class C4MenuWindow
|
|||
void OnMouseIn(int32_t player); // called by this window, sets "hasMouseFocus" from false to true
|
||||
|
||||
// properties are stored extra to make "tags" possible
|
||||
C4MenuWindowProperty props[C4MenuWindowPropertyName::_lastProp];
|
||||
C4GuiWindowProperty props[C4GuiWindowPropertyName::_lastProp];
|
||||
void Init();
|
||||
// withMultipleFlag is there to draw only the non-multiple or the multiple windows
|
||||
// withMultipleFlag == -1: all windows are drawn (standard)
|
||||
|
@ -209,17 +210,17 @@ class C4MenuWindow
|
|||
// ID is set by parent, parent gives unique IDs to children
|
||||
void SetID(int32_t to) { id = to; }
|
||||
// to be used to generate the quick-access children map for main menus
|
||||
void ChildGotID(C4MenuWindow *child);
|
||||
void ChildWithIDRemoved(C4MenuWindow *child);
|
||||
std::multimap<int32_t, C4MenuWindow *> childrenIDMap;
|
||||
void ChildGotID(C4GuiWindow *child);
|
||||
void ChildWithIDRemoved(C4GuiWindow *child);
|
||||
std::multimap<int32_t, C4GuiWindow *> childrenIDMap;
|
||||
// should be called when the Priority property of a child changes
|
||||
// will sort the child correctly into the children list
|
||||
void ChildChangedPriority(C4MenuWindow *child);
|
||||
void ChildChangedPriority(C4GuiWindow *child);
|
||||
// helper function
|
||||
// sets property value from possible(!) array
|
||||
void SetArrayTupleProperty(const C4Value &property, C4MenuWindowPropertyName first, C4MenuWindowPropertyName second, unsigned int hash);
|
||||
void SetArrayTupleProperty(const C4Value &property, C4GuiWindowPropertyName first, C4GuiWindowPropertyName second, unsigned int hash);
|
||||
|
||||
// this is only supposed to be called at ::MenuWindowRoot since it uses the "ID" property
|
||||
// this is only supposed to be called at ::GuiWindowRoot since it uses the "ID" property
|
||||
// this is done to make saving easier. Since IDs do not need to be sequental, action&menu IDs can both be derived from "id"
|
||||
int32_t GenerateMenuID() { return ++id; }
|
||||
int32_t GenerateActionID() { return ++id; }
|
||||
|
@ -246,17 +247,17 @@ class C4MenuWindow
|
|||
void SetVisible(bool f) { visible = f; }
|
||||
void SetTag(C4String *tag);
|
||||
|
||||
C4MenuWindow();
|
||||
C4MenuWindow(float stdBorderX, float stdBorderY);
|
||||
virtual ~C4MenuWindow();
|
||||
C4GuiWindow();
|
||||
C4GuiWindow(float stdBorderX, float stdBorderY);
|
||||
virtual ~C4GuiWindow();
|
||||
|
||||
int32_t GetID() { return id; }
|
||||
// finds a child with a certain ID, usually called on ::MainWindowRoot to get submenus
|
||||
C4MenuWindow *GetChildByID(int32_t child);
|
||||
C4GuiWindow *GetChildByID(int32_t child);
|
||||
// finds any fitting sub menu - not necessarily direct child
|
||||
// has to be called on children of ::MainWindowRoot, uses the childrenIDMap
|
||||
// note: always checks the target to avoid ambiguities, even if 0
|
||||
C4MenuWindow *GetSubWindow(int32_t childID, C4Object *childTarget);
|
||||
C4GuiWindow *GetSubWindow(int32_t childID, C4Object *childTarget);
|
||||
|
||||
|
||||
|
||||
|
@ -265,12 +266,12 @@ class C4MenuWindow
|
|||
// if isUpdate is true, all new children will have resetStdTag set
|
||||
bool CreateFromPropList(C4PropList *proplist, bool resetStdTag = false, bool isUpdate = false);
|
||||
|
||||
// C4MenuWindow will delete its children on close. Make sure you don't delete anything twice
|
||||
C4MenuWindow *AddChild(C4MenuWindow *child);
|
||||
C4MenuWindow *AddChild() { return AddChild(new C4MenuWindow()); }
|
||||
// C4GuiWindow will delete its children on close. Make sure you don't delete anything twice
|
||||
C4GuiWindow *AddChild(C4GuiWindow *child);
|
||||
C4GuiWindow *AddChild() { return AddChild(new C4GuiWindow()); }
|
||||
|
||||
void ClearChildren(bool close = true); // close: whether to properly "Close" them, alias for RemoveChild
|
||||
void RemoveChild(C4MenuWindow *child, bool close = true, bool all = false); // child = 0 & all = true to clear all
|
||||
void RemoveChild(C4GuiWindow *child, bool close = true, bool all = false); // child = 0 & all = true to clear all
|
||||
void Close();
|
||||
void ClearPointers(C4Object *pObj);
|
||||
|
||||
|
@ -287,6 +288,6 @@ class C4MenuWindow
|
|||
virtual bool MouseInput(int32_t player, int32_t button, int32_t mouseX, int32_t mouseY, DWORD dwKeyParam);
|
||||
};
|
||||
|
||||
extern C4MenuWindow MenuWindowRoot;
|
||||
extern C4GuiWindow GuiWindowRoot;
|
||||
|
||||
#endif
|
|
@ -42,7 +42,7 @@
|
|||
#include <C4PlayerList.h>
|
||||
#include <C4GameObjects.h>
|
||||
#include <C4GameControl.h>
|
||||
#include <C4MenuWindow.h>
|
||||
#include <C4GuiWindow.h>
|
||||
|
||||
const int32_t C4MC_Drag_None = 0,
|
||||
C4MC_Drag_Script = 6,
|
||||
|
@ -326,7 +326,7 @@ void C4MouseControl::Move(int32_t iButton, int32_t iX, int32_t iY, DWORD dwKeyFl
|
|||
// are custom menus active?
|
||||
bool menuProcessed = false;
|
||||
if (pPlayer)
|
||||
menuProcessed = ::MenuWindowRoot.MouseInput(Player, iButton, iX, iY, dwKeyFlags);
|
||||
menuProcessed = ::GuiWindowRoot.MouseInput(Player, iButton, iX, iY, dwKeyFlags);
|
||||
|
||||
// if not caught by a menu
|
||||
if (!menuProcessed)
|
||||
|
|
Loading…
Reference in New Issue