Merge lp:~widelands-dev/widelands/handle_tab into lp:widelands

Proposed by Tino
Status: Merged
Merged at revision: 6851
Proposed branch: lp:~widelands-dev/widelands/handle_tab
Merge into: lp:widelands
Diff against target: 193 lines (+56/-16)
9 files modified
CMakeLists.txt (+1/-1)
src/logic/playercommand.h (+2/-1)
src/map_io/widelands_map_scripting_data_packet.cc (+5/-4)
src/network/netclient.h (+4/-2)
src/network/nethost.cc (+2/-1)
src/ui_basic/editbox.cc (+7/-3)
src/ui_basic/panel.cc (+27/-1)
src/ui_fsmenu/loadgame.h (+2/-1)
src/wlapplication.cc (+6/-2)
To merge this branch: bzr merge lp:~widelands-dev/widelands/handle_tab
Reviewer Review Type Date Requested Status
SirVer Approve
Shevonar Needs Fixing
Review via email: mp+209406@code.launchpad.net

Description of the change

1) Do not put a control char on tab press into input boxes
2) Allow tabbing between input fields (e.g. metaserver login)
3) some code style fixes
4) Small fix in CMakelist.txt to avoid redundant appending of linker flag on each generate

To post a comment you must log in.
Revision history for this message
Shevonar (shevonar) wrote :

I just noticed a little misinterpretation: case SDLK_KP_ENTER is actually not an empty switch case. It just falls through to case SDLK_RETURN to handle the Enter key on the keypad the same way as the Return key. A case is only redundant if it falls through to the default case. Even a case foo: break; might be useful as it prevents the default case from execution.

review: Needs Fixing
Revision history for this message
Tino (tino79) wrote :

You are right, i've put back that case distinction.

Revision history for this message
SirVer (sirver) wrote :

lgtm.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2014-01-19 11:47:38 +0000
3+++ CMakeLists.txt 2014-03-05 12:50:28 +0000
4@@ -309,7 +309,7 @@
5 endif (DEFINED MSVC)
6
7 IF (MINGW)
8- set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--large-address-aware" CACHE STRING "Set by widelands CMakeLists.txt" FORCE)
9+ set (CMAKE_EXE_LINKER_FLAGS "-Wl,--large-address-aware" CACHE STRING "Set by widelands CMakeLists.txt" FORCE)
10 message (STATUS "Enabled large address awareness on mingw32")
11 endif (MINGW)
12
13
14=== modified file 'src/logic/playercommand.h'
15--- src/logic/playercommand.h 2014-02-22 18:04:02 +0000
16+++ src/logic/playercommand.h 2014-03-05 12:50:28 +0000
17@@ -132,7 +132,8 @@
18 };
19
20 struct Cmd_BuildRoad:public PlayerCommand {
21- Cmd_BuildRoad() : PlayerCommand(), path(nullptr), start(), nsteps(0), steps(nullptr) {} // For savegame loading
22+ Cmd_BuildRoad() :
23+ PlayerCommand(), path(nullptr), start(), nsteps(0), steps(nullptr) {} // For savegame loading
24 Cmd_BuildRoad (int32_t, int32_t, Path &);
25 Cmd_BuildRoad (StreamRead &);
26
27
28=== modified file 'src/map_io/widelands_map_scripting_data_packet.cc'
29--- src/map_io/widelands_map_scripting_data_packet.cc 2014-02-22 14:33:44 +0000
30+++ src/map_io/widelands_map_scripting_data_packet.cc 2014-03-05 12:50:28 +0000
31@@ -31,7 +31,7 @@
32 namespace Widelands {
33
34 namespace {
35-const int SCRIPTING_DATA_PACKET_VERSION=1;
36+const int SCRIPTING_DATA_PACKET_VERSION = 1;
37 } // namespace
38 /*
39 * ========================================================================
40@@ -53,9 +53,10 @@
41 // wise this makes no sense.
42 upcast(Game, g, &egbase);
43 Widelands::FileRead fr;
44- if (g and fr.TryOpen(fs, "scripting/globals.dump")) {
45- const uint32_t sentinel = fr.Unsigned32();
46- const uint32_t packet_version = fr.Unsigned32();
47+ if (g and fr.TryOpen(fs, "scripting/globals.dump"))
48+ {
49+ const uint32_t sentinel = fr.Unsigned32();
50+ const uint32_t packet_version = fr.Unsigned32();
51 if (sentinel != 0xDEADBEEF && packet_version != SCRIPTING_DATA_PACKET_VERSION) {
52 throw game_data_error(
53 "This savegame is from an older version of Widelands and can not be loaded any more.");
54
55=== modified file 'src/network/netclient.h'
56--- src/network/netclient.h 2014-02-22 18:04:02 +0000
57+++ src/network/netclient.h 2014-03-05 12:50:28 +0000
58@@ -79,9 +79,11 @@
59 uint32_t maxplayers,
60 bool savegame = false) override;
61 virtual void setPlayerState (uint8_t number, PlayerSettings::State state) override;
62- virtual void setPlayerAI (uint8_t number, const std::string & ai, bool const random_ai = false) override;
63+ virtual void setPlayerAI
64+ (uint8_t number, const std::string & ai, bool const random_ai = false) override;
65 virtual void nextPlayerState (uint8_t number) override;
66- virtual void setPlayerTribe (uint8_t number, const std::string & tribe, bool const random_tribe = false) override;
67+ virtual void setPlayerTribe
68+ (uint8_t number, const std::string & tribe, bool const random_tribe = false) override;
69 virtual void setPlayerInit (uint8_t number, uint8_t index) override;
70 virtual void setPlayerName (uint8_t number, const std::string & name) override;
71 virtual void setPlayer (uint8_t number, PlayerSettings ps) override;
72
73=== modified file 'src/network/nethost.cc'
74--- src/network/nethost.cc 2014-02-22 18:04:02 +0000
75+++ src/network/nethost.cc 2014-03-05 12:50:28 +0000
76@@ -211,7 +211,8 @@
77 h->setPlayerState(number, newstate, true);
78 }
79
80- virtual void setPlayerTribe(uint8_t const number, const std::string & tribe, bool const random_tribe) override
81+ virtual void setPlayerTribe
82+ (uint8_t const number, const std::string & tribe, bool const random_tribe) override
83 {
84 if (number >= h->settings().players.size())
85 return;
86
87=== modified file 'src/ui_basic/editbox.cc'
88--- src/ui_basic/editbox.cc 2013-07-26 20:19:36 +0000
89+++ src/ui_basic/editbox.cc 2014-03-05 12:50:28 +0000
90@@ -226,8 +226,12 @@
91 switch (code.sym) {
92 case SDLK_ESCAPE:
93 cancel();
94- return true;
95-
96+ return true;
97+
98+ case SDLK_TAB:
99+ //let the panel handle the tab key
100+ return false;
101+
102 case SDLK_KP_ENTER:
103 case SDLK_RETURN:
104 // Save history if active and text is not empty
105@@ -394,7 +398,7 @@
106 }
107 }
108
109- return Panel::handle_key(down, code);
110+ return false;
111 }
112
113 /**
114
115=== modified file 'src/ui_basic/panel.cc'
116--- src/ui_basic/panel.cc 2014-02-25 19:45:27 +0000
117+++ src/ui_basic/panel.cc 2014-03-05 12:50:28 +0000
118@@ -679,8 +679,34 @@
119 *
120 * \return true if the event was processed, false otherwise
121 */
122-bool Panel::handle_key(bool, SDL_keysym)
123+bool Panel::handle_key(bool down, SDL_keysym code)
124 {
125+ if (down) {
126+ if (_focus) {
127+ Panel * p = _focus->_next;
128+ switch (code.sym) {
129+
130+ case SDLK_TAB:
131+ while (p != _focus) {
132+ if (p->get_can_focus()) {
133+ p->focus();
134+ p->update();
135+ break;
136+ }
137+ if (p == _lchild) {
138+ p = _fchild;
139+ }
140+ else {
141+ p = p->_next;
142+ }
143+ }
144+ return true;
145+
146+ default:
147+ return false;
148+ }
149+ }
150+ }
151 return false;
152 }
153
154
155=== modified file 'src/ui_fsmenu/loadgame.h'
156--- src/ui_fsmenu/loadgame.h 2014-02-22 18:04:02 +0000
157+++ src/ui_fsmenu/loadgame.h 2014-03-05 12:50:28 +0000
158@@ -46,7 +46,8 @@
159
160 /// Select a Saved Game in Fullscreen Mode. It's a modal fullscreen menu.
161 struct Fullscreen_Menu_LoadGame : public Fullscreen_Menu_Base {
162- Fullscreen_Menu_LoadGame(Widelands::Game &, GameSettingsProvider * gsp = nullptr, GameController * gc = nullptr);
163+ Fullscreen_Menu_LoadGame
164+ (Widelands::Game &, GameSettingsProvider * gsp = nullptr, GameController * gc = nullptr);
165
166 const std::string & filename() {return m_filename;}
167
168
169=== modified file 'src/wlapplication.cc'
170--- src/wlapplication.cc 2014-02-22 18:04:02 +0000
171+++ src/wlapplication.cc 2014-03-05 12:50:28 +0000
172@@ -1899,7 +1899,8 @@
173 s.players[number].state = PlayerSettings::stateComputer;
174 }
175
176- virtual void setPlayerTribe(uint8_t const number, const std::string & tribe, bool const random_tribe) override
177+ virtual void setPlayerTribe
178+ (uint8_t const number, const std::string & tribe, bool const random_tribe) override
179 {
180 if (number >= s.players.size())
181 return;
182@@ -1979,7 +1980,10 @@
183
184 virtual std::string getWinCondition() override {return s.win_condition;}
185 virtual void setWinCondition(std::string wc) override {s.win_condition = wc;}
186- virtual void nextWinCondition() override {assert(false);} // not implemented - feel free to do so, if you need it.
187+ virtual void nextWinCondition() override // not implemented - feel free to do so, if you need it
188+ {
189+ assert(false);
190+ }
191
192 private:
193 GameSettings s;

Subscribers

People subscribed via source and target branches

to status/vote changes: