Ticket #8711: backends-lib.v5.3

File backends-lib.v5.3, 3.4 KB (added by SF/sbatyuk, 13 years ago)

port specific tabs patch

Line 
1Index: backends/platform/sdl/sdl.cpp
2===================================================================
3--- backends/platform/sdl/sdl.cpp (revision 28758)
4+++ backends/platform/sdl/sdl.cpp (working copy)
5@@ -473,3 +473,25 @@
6 _cdEndTime = SDL_GetTicks() + _cdrom->track[_cdTrack].length * 1000 / CD_FPS;
7 }
8 }
9+
10+enum {
11+ kCmdTestBtn = 'TEST'
12+};
13+
14+GUI::StaticTextWidget *_stw;
15+
16+void OSystem_SDL::generateBackendTab (GUI::GuiObject *boss) {
17+ new GUI::ButtonWidget(boss, "gameoptions_extrapath", "Click!", kCmdTestBtn, 'Q');
18+ _stw = new GUI::StaticTextWidget(boss, "gameoptions_id", "test");
19+}
20+
21+bool OSystem_SDL::handleBackendTabCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data) {
22+ switch(cmd) {
23+ case kCmdTestBtn:
24+ _stw->setEnabled(!_stw->isEnabled());
25+ _stw->draw();
26+ return true;
27+ default:
28+ return false;
29+ }
30+}
31Index: backends/platform/sdl/sdl.h
32===================================================================
33--- backends/platform/sdl/sdl.h (revision 28758)
34+++ backends/platform/sdl/sdl.h (working copy)
35@@ -34,6 +34,8 @@
36 #include "graphics/scaler.h"
37 #include "backends/intern.h"
38
39+#include "gui/object.h"
40+#include "gui/widget.h"
41
42 namespace Audio {
43 class Mixer;
44@@ -410,6 +412,18 @@
45 virtual bool remapKey(SDL_Event &ev, Common::Event &event);
46
47 void handleScalerHotkeys(const SDL_KeyboardEvent &key);
48+
49+ // backend lib methods
50+
51+public:
52+
53+ virtual Common::String getBackendTabName () {
54+ return "test";
55+ }
56+
57+ virtual void generateBackendTab (GUI::GuiObject *boss);
58+
59+ virtual bool handleBackendTabCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data);
60 };
61
62 #endif
63Index: common/system.h
64===================================================================
65--- common/system.h (revision 28758)
66+++ common/system.h (working copy)
67@@ -31,6 +31,8 @@
68 #include "common/noncopyable.h"
69 #include "common/rect.h"
70
71+#include "gui/object.h"
72+
73 namespace Audio {
74 class Mixer;
75 }
76@@ -885,6 +887,30 @@
77 */
78 virtual Common::SaveFileManager *getSavefileManager() = 0;
79
80+ // backend lib methods
81+
82+ // backend specific game options tab methods
83+
84+ /**
85+ * Returns the name of the backend specific tab in game edit dialog
86+ */
87+ virtual Common::String getBackendTabName() {
88+ return "";
89+ }
90+
91+ /**
92+ * Hook method to allow the backends generate their own specific tab in game edit dialog
93+ */
94+ virtual void generateBackendTab(GUI::GuiObject *boss) {}
95+
96+ /**
97+ * Hook method to allow the backends process the events from their
98+ * own specific tab in game edit dialog
99+ */
100+ virtual bool handleBackendTabCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data) {
101+ return false;
102+ }
103+
104 //@}
105 };
106
107 Index: gui/launcher.cpp
108===================================================================
109--- gui/launcher.cpp (revision 28758)
110+++ gui/launcher.cpp (working copy)
111@@ -259,6 +259,14 @@
112 _savePathWidget->setLabel("Default");
113 }
114
115+ //
116+ // 8) Backend tab
117+ //
118+ if (!g_system->getBackendTabName().empty()){
119+ tab->addTab(g_system->getBackendTabName());
120+ g_system->genereteBackendTab(tab);
121+ }
122+
123 // Activate the first tab
124 tab->setActiveTab(0);
125
126@@ -464,7 +472,9 @@
127 }
128 // FALL THROUGH to default case
129 default:
130- OptionsDialog::handleCommand(sender, cmd, data);
131+ if (!g_system->handleBackendTabCommand(sender, cmd, data)) {
132+ OptionsDialog::handleCommand(sender, cmd, data);
133+ }
134 }
135 }
136
137