Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Layout Editor running out of repositionable controls #958

Merged
merged 4 commits into from
Aug 19, 2018
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 93 additions & 0 deletions addons/ui/RscDisplayOptionsLayout.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
// Fixes Layout Editor only having 22 repositionable controls
class RscDisplayOptionsLayout {
class controlsBackground {
class Element021;
#define ADD_ELEMENT(var1) class Element##var1: Element021 {\
idc = __EVAL(12000 + var1);\
onMouseEnter = "with uinamespace do {['mouseEnter',_this,''] call RscDisplayOptionsLayout_script;};";\
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are the same config values set in each element? Aren't they inherited?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Eventhandlers are added by script. So no Element000->021 doesn't have them so we need to add them. Which is what's happening here.

But how about we just make Element022 with the Eventhandlers and just have all the others inherit from that? Less code in the preprocessed config in the end.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will take a look at the master config.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is how it looks in the displays init script:

// RscDisplayOptionsLayout.sqf
...
for "_i" from 0 to 21 do {
	_control = _display displayctrl (IDCBASE + _i);
	_control ctrladdeventhandler ["mouseenter","with uinamespace do {['mouseEnter',_this,''] call RscDisplayOptionsLayout_script;};"];
	_control ctrladdeventhandler ["mouseexit","with uinamespace do {['mouseExit',_this,''] call RscDisplayOptionsLayout_script;};"];
	_control ctrladdeventhandler ["mouseholding","with uinamespace do {['mouseMoving',_this,''] call RscDisplayOptionsLayout_script;};"];
	_control ctrladdeventhandler ["mousemoving","with uinamespace do {['mouseMoving',_this,''] call RscDisplayOptionsLayout_script;};"];
	_control ctrladdeventhandler ["mousebuttondown","with uinamespace do {['mouseButtonDown',_this,''] call RscDisplayOptionsLayout_script;};"];
	_control ctrladdeventhandler ["mousebuttonup","with uinamespace do {['mouseButtonUp',_this,''] call RscDisplayOptionsLayout_script;};"];
};
...

Strangely, in a few other places it just iterates through the child classes instead of assuming 0...21. /shrug

onMouseExit = "with uinamespace do {['mouseExit',_this,''] call RscDisplayOptionsLayout_script;};";\
onMouseHolding = "with uinamespace do {['mouseMoving',_this,''] call RscDisplayOptionsLayout_script;};";\
onMouseMoving = "with uinamespace do {['mouseMoving',_this,''] call RscDisplayOptionsLayout_script;};";\
onMouseButtonDown = "with uinamespace do {['mouseButtonDown',_this,''] call RscDisplayOptionsLayout_script;};";\
onMouseButtonUp = "with uinamespace do {['mouseButtonUp',_this,''] call RscDisplayOptionsLayout_script;};";\
}
ADD_ELEMENT(022);
ADD_ELEMENT(023);
ADD_ELEMENT(024);
ADD_ELEMENT(025);
ADD_ELEMENT(026);
ADD_ELEMENT(027);
ADD_ELEMENT(028);
ADD_ELEMENT(029);
ADD_ELEMENT(030);
ADD_ELEMENT(031);
ADD_ELEMENT(032);
ADD_ELEMENT(033);
ADD_ELEMENT(034);
ADD_ELEMENT(035);
ADD_ELEMENT(036);
ADD_ELEMENT(037);
ADD_ELEMENT(038);
ADD_ELEMENT(039);
ADD_ELEMENT(040);
ADD_ELEMENT(041);
ADD_ELEMENT(042);
ADD_ELEMENT(043);
ADD_ELEMENT(044);
ADD_ELEMENT(045);
ADD_ELEMENT(046);
ADD_ELEMENT(047);
ADD_ELEMENT(048);
ADD_ELEMENT(049);
ADD_ELEMENT(050);
ADD_ELEMENT(051);
ADD_ELEMENT(052);
ADD_ELEMENT(053);
ADD_ELEMENT(054);
ADD_ELEMENT(055);
ADD_ELEMENT(056);
ADD_ELEMENT(057);
ADD_ELEMENT(058);
ADD_ELEMENT(059);
ADD_ELEMENT(060);
ADD_ELEMENT(061);
ADD_ELEMENT(062);
ADD_ELEMENT(063);
ADD_ELEMENT(064);
ADD_ELEMENT(065);
ADD_ELEMENT(066);
ADD_ELEMENT(067);
ADD_ELEMENT(068);
ADD_ELEMENT(069);
ADD_ELEMENT(070);
ADD_ELEMENT(071);
ADD_ELEMENT(072);
ADD_ELEMENT(073);
ADD_ELEMENT(074);
ADD_ELEMENT(075);
ADD_ELEMENT(076);
ADD_ELEMENT(077);
ADD_ELEMENT(078);
ADD_ELEMENT(079);
ADD_ELEMENT(080);
ADD_ELEMENT(081);
ADD_ELEMENT(082);
ADD_ELEMENT(083);
ADD_ELEMENT(084);
ADD_ELEMENT(085);
ADD_ELEMENT(086);
ADD_ELEMENT(087);
ADD_ELEMENT(088);
ADD_ELEMENT(089);
ADD_ELEMENT(090);
ADD_ELEMENT(091);
ADD_ELEMENT(092);
ADD_ELEMENT(093);
ADD_ELEMENT(094);
ADD_ELEMENT(095);
ADD_ELEMENT(096);
ADD_ELEMENT(097);
ADD_ELEMENT(098);
ADD_ELEMENT(099);
};
};
2 changes: 1 addition & 1 deletion addons/ui/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ class CfgPatches {

#include "CfgEventHandlers.hpp"
#include "CfgFunctions.hpp"

#include "RscTitles.hpp"
#include "CfgUIGrids.hpp"
#include "RscDisplayOptionsLayout.hpp"

//-----------------------------------------------------------------------------
// TODO: Delete these rsc/_flexiMenu_RscShortcutButton classes soon and transfer properties to menu classes, if any.
Expand Down