Commit graph

202 commits

Author SHA1 Message Date
Kp dac1a69f7c Pass canvas to gr_ubox 2017-01-01 00:45:44 +00:00
Kp 7439949595 Pass canvas to gr_uline 2016-12-29 03:27:10 +00:00
Kp dc881ec12d Merge pull #266 into master 2016-11-19 18:09:26 +00:00
Kp 6db96d1a6d Fix file.cpp -Wunused-but-set-variable
Commit 1c8ad24 removed all reads of `wind`, but did not remove its
assignment or declaration.  This breaks the build with gcc due to
-Wunused-but-set-variable.

Fixes: 1c8ad24da3 ("Check for window_event_result::deleted for ui_get_filename polling loop")
2016-11-19 17:24:51 +00:00
Kp 98afafb80f Fix gadget.cpp -Wunused-but-set-variable
Commit 917f079 removed all reads of `wind`, but did not remove its
assignment or declaration.  This breaks the build with gcc due to
-Wunused-but-set-variable.

Fixes: 917f079f02 ("Check for window_event_result::deleted in ui_dialog_do_gadgets")
2016-11-19 17:24:51 +00:00
Chris Taylor cc3f35649f Change all occurrences of "Couldn't" to "Could not" for consistency ("Could not" is more common and wins).
Not touching TXT_COULDNT because it's stored separately in hog file.
2016-11-13 13:27:18 +08:00
Chris Taylor 1761d696fe Check if dir is empty string the more efficient way in file_getdirlist 2016-11-13 12:49:08 +08:00
Chris Taylor 5f19a3cba9 Remove redundant checks and initialisations recently added for editor 2016-11-13 12:44:53 +08:00
Chris Taylor 2d5d24cedc Fix freeze when clicking on 'Help' menu in editor
The functions med-mark-start and med-mark-end don't exist - that's fine, still read the rest of the menus, so it can actually properly 'hide' the help menu after it's clicked on.
2016-11-11 18:11:14 +08:00
Chris Taylor ac438f4cc2 Allow the user to carry on as usual if any of the editor files are missing (i.e. before editor was loaded).
If a game was playing, continue playing. If it was in the main menu, return to the main menu. (If all files are put in place the editor can load again.)
2016-11-11 16:09:57 +08:00
Chris Taylor e29a4513b6 Allow empty string to be passed to file_getdirlist
This allows the open/save dialogs to work in the editor when a filename without a path separator is passed (which is the default)
2016-11-11 16:09:57 +08:00
Chris Taylor 46297c151e Remove ui_gadget_delete_all
As the UI_DIALOG client is now responsible for freeing all gadgets (via unique_ptr's), this function now causes issues where it attempts to access freed gadgets (resulting in std::runtime_error("unknown gadget kind") exception when closing the AI Properties dialog on my Macbook, for example). Removing the offending function fixes the issue.
2016-11-11 16:09:57 +08:00
Chris Taylor 9511f65a90 Declare some local window_event_result vars later (clarity) 2016-10-31 14:58:34 +08:00
Chris Taylor 7ac820248c Use new event_process_all() for event loops that check for window_event_result::deleted (which is most of them) 2016-10-29 20:06:01 +08:00
Chris Taylor 1c8ad24da3 Check for window_event_result::deleted for ui_get_filename polling loop
This is instead of using window_exists, which could give a false positive if a new window was allocated with the same pointer value as a deleted one.
2016-10-28 15:25:25 +08:00
Chris Taylor 917f079f02 Check for window_event_result::deleted in ui_dialog_do_gadgets
This is instead of using window_exists, which could give a false positive if a new window was allocated with the same pointer value as a deleted one.
2016-10-28 08:40:50 +08:00
Chris Taylor 7b83123010 Pass window_event_result from a dialog handler all the way to the event system
In particular, window_event_result::deleted so the event system doesn't have to rely on the somewhat problematic window_exists. If a gadget is manipulated, it still returns at least window_event_result::handled so all the other gadgets in all the other windows don't have to be checked (that weren't already checked).
2016-10-27 19:42:48 +08:00
Chris Taylor 18062bf812 Make browser_handler (editor file opening dialog) return window_event_result::close instead of closing itself
This ensures the event system will know what's going on.
2016-10-27 17:38:20 +08:00
Chris Taylor 66de1a1823 Make sure if a UI_DIALOG handler returns window_event_result::close or window_event_result::deleted, it will be passed onto window_send_event 2016-10-27 17:12:17 +08:00
Kp 01f2932824 Pass grs_canvas &to window_create 2016-10-15 00:53:20 +00:00
Chris Taylor bc1c9ebd97 Merge branch 'unification/master' into allow_dialog_subclass
Conflicts:
	common/arch/sdl/window.cpp - Remove unused EVENT_WINDOW_CLOSED and w_callback local var
	common/ui/dialog.cpp - Remove unused EVENT_WINDOW_CLOSED
2016-10-10 14:40:11 +08:00
Kp 1af65071d7 Remove unused EVENT_WINDOW_CLOSED
Every callee that recognized EVENT_WINDOW_CLOSED did so only to
explicitly ignore it.  Remove the code to send it and all sites that
ignored it.
2016-10-10 00:25:15 +00:00
Chris Taylor 9631d319f6 Allow dcx::UI_DIALOG struct to be subclassed - step 3
Allow dcx::UI_DIALOG struct to be subclassed step 3. This step adds the destructor and makes sure the dialog is only deleted within the main dialog handler if the specific handler didn't return window_event_result::deleted.
2016-10-04 16:09:21 +08:00
Chris Taylor db665d8c33 Allow dcx::UI_DIALOG struct to be subclassed - step 2
Allow dcx::UI_DIALOG struct to be subclassed step 2. Make all the UI_DIALOG handlers return a window_event_result like everyone else.
2016-10-04 15:58:20 +08:00
Chris Taylor 60ac1eaad3 Replace delete dcx::window kludge with a better solution
Replace delete dcx::window kludge with a better solution: instead of requiring every handler to delete the window, add a window_event_result::deleted, which gets returned if the window was deleted by the handler, so window_close knows not to attempt to delete it again.
2016-10-04 14:05:44 +08:00
Chris Taylor 4d9eb4e743 Allow dcx::UI_DIALOG struct to be subclassed - step 1
Allow dcx::UI_DIALOG struct to be subclassed step 1. This step renames and reconfigures untyped_ui_dialog_create in dialog.cpp to be the main constructor. Also adds a template constructor that allows an event handler that takes a subclass of UI_DIALOG.
2016-10-04 11:29:19 +08:00
Chris Taylor 87617e8ac9 Allow dcx::window struct to be subclassed - step 3
Allow dcx::window struct to be subclassed step 3. This step adds the window destructor and both requires and implements the window to be deleted by the event handler/client in all cases.
2016-10-02 17:49:19 +08:00
Kp e06d8b33aa Reuse string_array_sort_func for file_sort_func
Both functions have the same implementation, so delete static
file_sort_func and use string_array_sort_func.
2016-09-04 19:10:43 +00:00
Kp 2e88fec559 Flatten some ui type hierarchy 2016-08-06 19:55:24 +00:00
Kp c636dc4b98 Convert various static const expressions to constexpr 2016-07-16 16:52:04 +00:00
Kp b6fd8572d1 Simplify ui_radio_set_value loop 2016-07-06 01:54:25 +00:00
Kp e92a7aea14 Use C++ static_cast for gadget downcast 2016-07-06 01:54:25 +00:00
Kp 65f68877aa Rewrite simple integer casts from C style to static_cast<>
This pass only targets commonly used standard types.

s/(\(\s*\(\(un\)\?signed\|int\|char\|short\|long\|float\|double\|s\?size_t\|\(u\?int[[:digit:]]\+_t\)\)\)\s*)\s*(/static_cast<\1>(/g
2016-06-16 03:56:44 +00:00
Kp 1b12a3f7ef Add parentheses around target of more complicated casts
C casts do not require parentheses.  C++ casts require grouping around
the target.  Prepare for conversion to C++ casts by adding otherwise
unnecessary parentheses around the target of some C casts.

This pass attempts to process expressions that involve parenthesized or
bracketed subexpressions, but only if those subexpressions do not
themselves contain parenthesized or bracketed subexpressions.

	(int) f(1);	// changed
	(int) f(g());	// not changed

perl -p -i -e 's/(\(\s*((?:un)?signed|int|char|short|long|float|double|s?size_t|(?:u?int[[:digit:]]+_t))\s*\**\s*\)\s*)([&+-]?)([[:alnum:]_.]+\s*->\s*)*([[:alnum:]_.]+)((?:\s*(?:\[[^][]*\])*|(?:\([^()]*\))*))(\s*([;+>*\/^%,|&<>])|$|(\s*-\s*[^>]))/\1\(\3\4\5\6\)\7/g'
2016-06-12 03:45:37 +00:00
Kp bc30ccd216 Rewrite cast of (sbyte) to standard type int8_t
s/(sbyte)\s*\(\w\)/(int8_t) \1/g
2016-06-12 03:45:37 +00:00
Kp 1789643480 Remove UserError on unknown MED function
Jayman2000 reports that users who do not update their MED.MNU after
updating to 8b61b9f ("Remove unused symbols") receive an "editor crash"
on startup.  This is not a crash, but instead is poor error handling in
menubar.cpp, which calls UserError instead of ignoring the offending
line.  Calls to UserError are fatal, but do not crash the program.
Replace that call with a con_printf(CON_URGENT) and ignore the line.

Additionally, change the handling for excess menus and for excess menu
items to con_printf+ignore instead of UserError.

Reported-by: Jayman2000 <https://github.com/dxx-rebirth/dxx-rebirth/pull/190>
Fixes: 8b61b9f0db ("Remove unused symbols")
2016-04-03 17:50:42 +00:00
Kp 27cef20eb3 Move namespace dsx handling to dsx-ns.h 2016-03-19 19:08:10 +00:00
Kp 08de1bbff0 Remove cv_color
It is only ever set to 0 or copied from other canvases.  Set it to zero
everywhere.
2016-02-12 04:02:28 +00:00
Kp f4e1ebb576 Remove unnecessary gr_setcolor calls 2016-02-12 04:02:28 +00:00
Kp e09a590e6f Pass color to Vline 2016-02-12 04:02:28 +00:00
Kp 76d0e01b6e Pass color to Hline 2016-02-12 04:02:28 +00:00
Kp de08a67321 Pass color to gr_ubox 2016-02-12 04:02:28 +00:00
Kp 23047b1165 Pass color to gr_rect 2016-02-12 04:02:28 +00:00
Kp 35a4736df0 Pass color to gr_urect 2016-02-12 04:02:28 +00:00
Kp 053901b62b Pass color to gr_uline 2016-02-12 04:02:28 +00:00
Kp b57f08c798 Use partial_const_range 2016-02-12 04:02:28 +00:00
Kp eb3fe7acdb Remove sprintf from menubar.cpp 2016-01-09 16:38:16 +00:00
Kp dc8c0323d8 Uninline namespace dcx 2015-12-13 18:00:49 +00:00
Kp 22bd3ce8d8 Use inline namespace dcx for common/ui 2015-12-05 22:57:24 +00:00
Kp ed55763603 Remove unused symbols 2015-12-04 03:36:31 +00:00