Commit Graph

48 Commits (master)

Author SHA1 Message Date
David Dormagen 3acd4a22f2 take 'left' and 'player' (and more) out of global namespace
The values from the enums are converted to numbers a lot, so using an enum class would be counter-productive.
Having 'left' in the global namespace appeared to be an actual problem with some Qt headers, according to Fulgen.
2018-01-20 18:20:51 +01:00
Tushar Maheshwari 3a4f49ad90 Revisit #includes
Consolidate the include statements scattered across the code in accordance
with the comment in C4Include.h. The advantages are listed in the same
comment.
Furthermore, it follows llvm-include-order which is the logical
extrapolation of the project's style guideline wherever possible
(C4Include.h being the most-frequent exception).
2017-05-15 13:24:59 +02:00
Tushar Maheshwari e58a7884e4 Automatic fixes using clang-tidy
See http://forum.openclonk.org/topic_show.pl?tid=3376 for discussion.

Close GH-41
2017-05-03 20:30:45 +02:00
David Dormagen 8a8593e0ba Script GUI: added TightGridLayout style (requirement of #1842)
The TightGridLayout fills spaces more aggressively. This is slower but makes for a tighter layout. Finding the best layout is NP-complete. This here is just O(N^2) or so.
2016-11-05 15:35:15 +01:00
Sven Eberhardt ebda8193ef Replace NULL by nullptr in C++ sources
We don't support pre-C++0x any more, so nullptr should be fine everywhere (except in the plain C source files)
2016-11-02 19:58:02 -04:00
Julius Michaelis 8d2f2846b5 Fix mac build
Also move some stuff around once again…
2016-10-21 01:25:48 +02:00
Sven Eberhardt cf7134e60e Fix a few warnings / possible divisions by zero 2016-10-08 20:51:51 -04:00
David Dormagen 60b9558b56 script GUIs: fixed clipping over parent's boundaries (#1718)
The window would always use its very own rectangle for clipping - bad luck if it was larger than the parent.
Now children can only additionally restrict the parent rectangle (which defaults to the whole screen at root).
2016-04-17 22:28:34 +02:00
Nicolas Hake eabca223f5 Update all copyright notices for 2016 2016-04-03 20:24:42 +02:00
Nicolas Hake 493c276126 Rewrite header inclusions to #include "path/to/file.h" style 2016-04-03 20:24:42 +02:00
Nicolas Hake 0537df5f23 C4Object: Move C4Def.h dep out of header
C4Def is only ever used as a pointer inside C4Object.h, so we don't need
to include C4Def.h from it.
2016-04-03 13:24:26 +02:00
Nicolas Hake 4fdafbc78a Move StdColors.h ref from C4Surface.h to files that actually need it
C4Surface.h doesn't require anything from StdColors.h, so there's no
reason to reference the latter there.
2016-02-08 02:13:18 +01:00
David Dormagen 59739b5cf6 script GUIs: do not catch mouse-up without prior mouse-down (#1327)
Otherwise, you could open a menu on mouse-down, which would then block the mouse-up event. The control system (not the script but the engine!) would then never know that the button was released and issue a key event with repeated=1 when you pressed the button the next time.
This could lead to issues.
2016-02-07 10:47:33 +01:00
David Dormagen 6c5294a05f fixed invisible UI elements accepting player input
When an UI element was only visible to a player (via the Player property), it still allowed ALL players to click on buttons.
I am wondering why noone else noticed that bug before. It's possible that it didn't show when the visibility was set via the menu's Target (instead of the Player property).

Maybe this was the cause of the "clicks sometimes do nothing" bug?
2016-01-31 23:36:06 +01:00
David Dormagen 8418da86d6 custom GUIs: fixed scrollbar offset with active upper board (#1612)
I guess the UI elements expect their position to already be corrected by cgo.X/Y. Or they never cared because they were in front of the upper board.
I am not sure, maybe the correct solution would be to actually position all elements lower (instead of adjusting for it when passing mouse input or drawing)? Currently the position is relative to the upper board's edge.

Anyway, this works for now.
2016-01-21 22:17:47 +01:00
David Dormagen 8ba1e042a0 script GUIs: fixed clipping with active upper board
I know that the issue was noticable starting from https://git.openclonk.org/openclonk.git/commit/cd57e474935b283e58c7ae7edd137c049f87f90c
I don't know WHY it was not noticable before, though. It had probably always been a defect.
2016-01-20 22:30:35 +01:00
David Dormagen 9292718ca5 script GUIs: fix auto-height window size with pure text windows
Otherwise, if a window was GUI_FitChildren and the text would NOT trigger a scrollbar, the window height was set to 0 (because the text height was only taken into account when rawTextHeight - 1 > rcBounds.Hgt).
2016-01-20 10:33:11 +01:00
David Dormagen cd57e47493 script GUIs: fixed text clipping and scrolling (#1605, related to #1612)
Previously, text windows would just change their own size and leave cropping and scrolling to their parent. This made the code easier, but was apparently unintuitive for scripters.
Now text windows do not change their size but show a scrollbar themselves (unless GUI_FitChildren or GUI_NoCrop of course).

This implied some other changes, because now parents without a scroll bar need to clip, too. (Or the clipping needs to be moved to the child window. But then it would have to be made sure that menu decoration can still go out of the bounds.)
And this also needed some script fixes where scripters assumed the text windows would not scroll (and thus made them smaller than 1em).

related to https://git.openclonk.org/openclonk.git/commit/46ad28ea652fad34814a866f3b9c305aa7cc6faa
2016-01-18 21:39:54 +01:00
David Dormagen ba2cf8f096 fix incorrect clipping in script GUI windows (#1592)
I am not sure why the 'isMainWindow' was there. It wasn't there in 7319f7b3cc and got introduced in the major rework in 049088be78 - I guess it was just an oversight that was not noticed because usually the UI windows have the text or other things that need to scroll on a deeper level.

Anyway, checking whether the window is a script-root window does not make any sense as far as I can see now.
2016-01-12 22:18:57 +01:00
Nicolas Hake 3c625a00dd C4Game: Turn some owned pointers into std::unique_ptr
Using std::unique_ptr instead of raw pointers makes ownership clear and
avoids leaks.
2015-12-28 11:43:37 +01:00
David Dormagen 65dc58c77d fixed wrong positioning of script GUI windows with the GUI_Multiple flag on startup (#1477)
GUI_Multiple windows are supposed to be updated from the root window in a full refresh. However, they also had the "dirty" flag set (that is only used for non GUI_Multiple windows after the initial startup), but they did not unset it when updating.
So they were first updated with the correct parent width (full screen) and then, because of the dirty flag, were updated again like a non GUI_Multiple window with the parent's size. That was incorrect. Only another update would then fix it again (because the "dirty" flag would then have been unset).
2015-12-27 15:48:32 +01:00
David Dormagen a6d11d67f5 custom GUI: grid layout now checks remaining row length before adding another element
Previously it was checked after adding an element. Long elements would thus be in the same row as the other elements even if they wouldn't fit. Not long elements get their own row.
2015-10-13 07:35:04 +02:00
Sven Eberhardt f5a0ff3d8f Script GUI: Process double click as second single click. 2015-10-03 22:43:06 -04:00
Julius Michaelis 2ad045f8d6 Replace strtod with stringstreams in C4ScriptGuiWindow::SetPositionStringProperties to avoid locale problems (second attempt)
Also added warnings and fixed a few whitespacing errors.
2015-10-03 13:17:17 +02:00
Nicolas Hake c8e1a38950 Revert "Replace strtod with strtof_l ..."
This reverts commit 139dee9874.

The commit introduced a memory leak on glibc, and broke the build on all
other platforms.
2015-10-01 20:50:40 +02:00
Julius Michaelis 139dee9874 Replace strtod with strtof_l in C4ScriptGuiWindow::SetPositionStringProperties to avoid locale problems
(That function could still use some more love, though: Error messages and not accepting ridiculous things when parsing.)
2015-10-01 19:50:05 +02:00
David Dormagen 6756db2768 C4ScriptGuiWindow: fix copyright header
The remaining old header has now been adjusted to the new one.
See e0dc30c59a for details.
2015-09-29 19:13:12 +02:00
David Dormagen 439cfac129 custom GUIs: do not break text when style flag NoCrop is set and set NoCrop for HP display 2015-09-25 15:01:24 +02:00
Sven Eberhardt 5b19294d76 Use ANY_OWNER instead of INT_MAX to label GUI elements shown to everyone.
Mostly to make the code more readable because there's no way to know that INT_MAX means "anyone".
2015-09-23 18:08:44 -04:00
David Dormagen f4f9afa477 custom guis: for the Player property, distinguish between NO_OWNER and nil
NO_OWNER means the message will be visible for noone (can f.e. be used to hide a ui window). nil means the message won't have visibility restrictions. This is probably what the scripter expects.
Previously, a value of "nil" would have been read as 0. So not setting the Player property and setting it to nil would mean two different things.
2015-09-23 22:03:29 +02:00
David Dormagen cc3452bd0d custom guis: properly scale with font size now
Previously, the em <-> pixels conversion was a hardcoded value. Now the GUI scales with the font size that can be selected in the options.
Sadly, all scales were off since the hardcoded value was too low.
2015-09-06 19:02:31 +02:00
Sven Eberhardt ec0b9a0dd1 Fix deleted object usage when script gui close call is issued in response to deleted parent object. 2015-09-05 20:37:12 -04:00
David Dormagen 4682b6c668 script GUIs: fixed a fistful of memory leaks
There are some ownership rules (PropList::GetProperties, Ui::Element..) which are not very clear imo. But there also was at least one clear oversight (name retaining, that is).
The only issue would be an assertion firing at game exit.
2015-09-05 11:01:58 +02:00
Sven Eberhardt cb995eb158 Fix several memory leaks in script gui. 2015-09-04 21:08:28 -04:00
Sven Eberhardt 8f4494745d Fix C4ScriptGuiWindow MouseInput/MouseEnter/MouseLeave overloads.
MouseInput silently shadowed the variant in C4GUI::Element and MouseEnter/MouseLeave were never called without parameters.
2015-09-03 23:27:20 -04:00
Sven Eberhardt 36fbbb34a4 Change deactivated MenuDebugLogF to a definition that does not evaluate its parameters. 2015-09-03 22:50:58 -04:00
Sven Eberhardt 20d3de46cd Fix some unused variables. 2015-09-03 21:26:49 -04:00
David Dormagen f05345375c fixed wrong offset in scripted GUIs when upper-board is active 2015-08-02 23:19:28 +02:00
David Dormagen d5f4805f18 fixed desync
The desync was caused by PropList->GetProperties returning the properties in an arbitrary order. They are now sorted first.
The debug logs are left in place, because I assume that I will need them again and they prove to be helpful.
2015-08-02 19:12:09 +02:00
David Dormagen 9968b0000c custom GUIs: restrict the maximum size of a menu window to 100em x ~62em
Fullscreen GUIs on wide-screen monitors look stupid. This patch tackles this by restricting the maximum size to something that can still be seen with a glance.
For very high-DPI or low-DPI screens, the user would most likely adjust the font size in the options (todo) anyway and thus also change the maximum menu size.
2015-03-27 11:33:57 +01:00
David Dormagen dae7f11a70 custom GUIs: added property GraphicsName to specify graphics of Symbol (if Symbol is a definition)
f.e. {Symbol = Icon_Number, GraphicsName = "Inf"}
2015-03-23 15:34:09 +01:00
David Dormagen ebcc397221 add proper support (inventory & interaction-menu contents) for extra slot library
Also fix bug with GuiScriptWindow where scrollbars would not be hidden in some cases (f.e. no-crop parent and negative-top child).
2015-03-19 16:22:06 +01:00
David Dormagen 4c69e19219 custom guis: correctly respect margins in grid layout and vertical layout 2015-01-20 20:44:13 +01:00
David Dormagen c42d94e3cf Script GUI: fixed a bug where a GUI's rectangle was incorrect 2015-01-03 15:30:30 +01:00
David Dormagen 64e092cd3e custom guis: fixed text alignment
C4ScriptGuiWindowStyleFlag should probably be a class enum. Or at least put in a separate namespace. This is TODO to prevent further name collisions. However, it's not completely trivial.
2014-12-26 12:18:17 +01:00
David Dormagen c2c80b94db custom gui: fixed FitChildren style flag 2014-12-26 11:50:40 +01:00
David Dormagen 6476b0b026 Script GUIs: fixed saving & loading 2014-10-23 23:29:14 +02:00
David Dormagen 2a78b77bda renamed C4GuiWindow to C4ScriptGuiWindow to increase expressivness and reduce similarity with C4Gui* 2014-10-13 18:48:03 +02:00