Przeglądaj źródła

Imgui update, controller & camera movement improvements.

Thomas Buck 9 lat temu
rodzic
commit
9dd7432bfd

+ 6
- 0
ChangeLog.md Wyświetl plik

@@ -2,6 +2,12 @@
2 2
 
3 3
 ## OpenRaider (0.1.3) xythobuz <xythobuz@xythobuz.de>
4 4
 
5
+    [ 20140211 ]
6
+    * Updated imgui to version 1.32
7
+    * Included some SDL game controller configurations
8
+    * Camera movement speed is now clamped when moving in multiple directions
9
+    * Slightly increased controller dead-zone, now 0.2
10
+
5 11
     [ 20140204 ]
6 12
     * Return of textile, animated textile and sprite viewer, in TextureManager
7 13
 

+ 1
- 1
include/Console.h Wyświetl plik

@@ -21,7 +21,7 @@ class Console {
21 21
     static void setVisible(bool v) { visible = v; }
22 22
 
23 23
   private:
24
-    static void callback(ImGuiTextEditCallbackData* data);
24
+    static int callback(ImGuiTextEditCallbackData* data);
25 25
 
26 26
     const static int bufferLength = 256;
27 27
 

+ 1
- 1
include/Entity.h Wyświetl plik

@@ -12,7 +12,7 @@ class Entity {
12 12
   public:
13 13
     Entity(int i, int r, glm::vec3 po, glm::vec3 ro)
14 14
         : id(i), room(r), pos(po), rot(ro), cache(-1), cacheType(-1),
15
-        sprite(0), animation(0), frame(0) { }
15
+          sprite(0), animation(0), frame(0) { }
16 16
     void display(glm::mat4 VP);
17 17
 
18 18
     int getID() { return id; }

+ 7
- 2
src/Camera.cpp Wyświetl plik

@@ -38,7 +38,7 @@ const static float nearDist = 0.1f;
38 38
 const static float farDist = 75000.0f;
39 39
 const static float maxSpeed = 3072.0f;
40 40
 const static float controllerViewFactor = glm::pi<float>();
41
-const static float controllerDeadZone = 0.1f;
41
+const static float controllerDeadZone = 0.2f;
42 42
 
43 43
 const static glm::vec3 rightUnit(1.0f, 0.0f, 0.0f);
44 44
 const static glm::vec3 upUnit(0.0f, 1.0f, 0.0f);
@@ -183,7 +183,12 @@ bool Camera::update() {
183 183
     glm::quat quatX = glm::angleAxis(rot.y, glm::vec3(1.0f, 0.0f, 0.0f));
184 184
     glm::quat quaternion = quatY * quatX;
185 185
 
186
-    pos += quaternion * posSpeed * dT;
186
+    glm::vec3 clampedSpeed(posSpeed);
187
+    if (glm::length(clampedSpeed) > maxSpeed) {
188
+        clampedSpeed = glm::normalize(clampedSpeed) * maxSpeed;
189
+    }
190
+
191
+    pos += quaternion * clampedSpeed * dT;
187 192
 
188 193
     glm::mat4 translate = glm::translate(glm::mat4(1.0f), pos);
189 194
     glm::mat4 rotate = glm::toMat4(quaternion);

+ 4
- 2
src/Console.cpp Wyświetl plik

@@ -21,7 +21,7 @@ std::vector<std::string> Console::lastCommands;
21 21
 long Console::lastCommandIndex = -1;
22 22
 std::string Console::bufferedCommand;
23 23
 
24
-void Console::callback(ImGuiTextEditCallbackData* data) {
24
+int Console::callback(ImGuiTextEditCallbackData* data) {
25 25
     bool update = false;
26 26
     std::string completion;
27 27
 
@@ -66,6 +66,8 @@ void Console::callback(ImGuiTextEditCallbackData* data) {
66 66
 
67 67
         data->CursorPos = strlen(data->Buf);
68 68
     }
69
+
70
+    return 0;
69 71
 }
70 72
 
71 73
 void Console::display() {
@@ -98,7 +100,7 @@ void Console::display() {
98 100
         if (ImGui::Button("Log to File")) { logToFile = true; }
99 101
         ImGui::Separator();
100 102
 
101
-        ImGui::BeginChild("ConsoleText", ImVec2(0, -ImGui::GetTextLineSpacing() * 2));
103
+        ImGui::BeginChild("ConsoleText", ImVec2(0, -ImGui::GetTextLineHeightWithSpacing() * 2));
102 104
         if (logToTTY)
103 105
             ImGui::LogToTTY();
104 106
         else if (logToClipboard)

+ 2
- 1
src/RoomData.cpp Wyświetl plik

@@ -86,7 +86,8 @@ void StaticModel::display(glm::mat4 VP) {
86 86
 
87 87
 void RoomSprite::display(glm::mat4 VP) {
88 88
     glm::mat4 translate = glm::translate(glm::mat4(1.0f), glm::vec3(pos.x, -pos.y, pos.z));
89
-    glm::mat4 rotate = glm::rotate(glm::mat4(1.0f), Camera::getRotation().x, glm::vec3(0.0f, 1.0f, 0.0f));
89
+    glm::mat4 rotate = glm::rotate(glm::mat4(1.0f), Camera::getRotation().x, glm::vec3(0.0f, 1.0f,
90
+                                   0.0f));
90 91
     glm::mat4 model = translate * rotate;
91 92
 
92 93
     getWorld().getSprite(sprite).display(VP * model);

+ 26
- 26
src/TextureManager.cpp Wyświetl plik

@@ -21,6 +21,30 @@
21 21
 #include "utils/strings.h"
22 22
 #include "TextureManager.h"
23 23
 
24
+glm::vec2 TextureTile::getUV(unsigned int i) {
25
+    glm::vec2 uv(vertices.at(i).xPixel,
26
+                 vertices.at(i).yPixel);
27
+
28
+    /*! \fixme
29
+     * This is my somewhat hacky approach to fixing
30
+     * the bad texture-bleeding problems everywhere.
31
+     * That's better, but makes the seams between
32
+     * each sector much more visible!
33
+     */
34
+
35
+    if (vertices.at(i).xCoordinate == 1) {
36
+        uv.x += 0.375f;
37
+    }
38
+
39
+    if (vertices.at(i).yCoordinate == 1) {
40
+        uv.y += 0.375f;
41
+    }
42
+
43
+    return uv / 256.0f;
44
+}
45
+
46
+// ----------------------------------------------------------------------------
47
+
24 48
 std::vector<unsigned int> TextureManager::mTextureIdsGame;
25 49
 std::vector<unsigned int> TextureManager::mTextureIdsSystem;
26 50
 std::vector<TextureTile*> TextureManager::tiles;
@@ -354,7 +378,7 @@ void TextureManager::display() {
354 378
         }
355 379
 
356 380
         auto bm = getBufferManager(index, game ? TextureStorage::GAME
357
-                                                            : TextureStorage::SYSTEM);
381
+                                   : TextureStorage::SYSTEM);
358 382
         ImGui::Image(bm, ImVec2(ImGui::GetColumnWidth() * 2 / 3, ImGui::GetColumnWidth() * 2 / 3));
359 383
     }
360 384
 
@@ -446,7 +470,7 @@ void TextureManager::display() {
446 470
             if (fr > 0) {
447 471
                 fr--;
448 472
             } else {
449
-                fr = RunTime::getFPS() / 2;
473
+                fr = RunTime::getFPS() / 5;
450 474
                 tile = next;
451 475
             }
452 476
         } else {
@@ -515,27 +539,3 @@ void TextureManager::display() {
515 539
     }
516 540
 }
517 541
 
518
-// ----------------------------------------------------------------------------
519
-
520
-glm::vec2 TextureTile::getUV(unsigned int i) {
521
-    glm::vec2 uv(vertices.at(i).xPixel,
522
-                 vertices.at(i).yPixel);
523
-
524
-    /*! \fixme
525
-     * This is my somewhat hacky approach to fixing
526
-     * the bad texture-bleeding problems everywhere.
527
-     * That's better, but makes the seams between
528
-     * each sector much more visible!
529
-     */
530
-
531
-    if (vertices.at(i).xCoordinate == 1) {
532
-        uv.x += 0.375f;
533
-    }
534
-
535
-    if (vertices.at(i).yCoordinate == 1) {
536
-        uv.y += 0.375f;
537
-    }
538
-
539
-    return uv / 256.0f;
540
-}
541
-

+ 1
- 1
src/UI.cpp Wyświetl plik

@@ -84,7 +84,7 @@ int UI::initialize() {
84 84
     int width, height;
85 85
     io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height);
86 86
     fontTex = TextureManager::loadBufferSlot(pixels, width, height, ColorMode::RGBA, 32,
87
-                                             TextureStorage::SYSTEM, -1, false);
87
+              TextureStorage::SYSTEM, -1, false);
88 88
     auto bm = TextureManager::getBufferManager(fontTex, TextureStorage::SYSTEM);
89 89
     io.Fonts->TexID = bm;
90 90
 

+ 907
- 394
src/deps/imgui/imgui.cpp
Plik diff jest za duży
Wyświetl plik


+ 78
- 42
src/deps/imgui/imgui.h Wyświetl plik

@@ -1,5 +1,5 @@
1
-// ImGui library v1.31 wip
2
-// See .cpp file for commentary.
1
+// ImGui library v1.32
2
+// See .cpp file for documentation.
3 3
 // See ImGui::ShowTestWindow() for sample code.
4 4
 // Read 'Programmer guide' in .cpp for notes on how to setup ImGui in your codebase.
5 5
 // Get latest version at https://github.com/ocornut/imgui
@@ -44,6 +44,7 @@ typedef int ImGuiWindowFlags;       // enum ImGuiWindowFlags_
44 44
 typedef int ImGuiSetCondition;      // enum ImGuiSetCondition_
45 45
 typedef int ImGuiInputTextFlags;    // enum ImGuiInputTextFlags_
46 46
 struct ImGuiTextEditCallbackData;   // for advanced uses of InputText() 
47
+typedef int (*ImGuiTextEditCallback)(ImGuiTextEditCallbackData *data);
47 48
 
48 49
 struct ImVec2
49 50
 {
@@ -159,25 +160,26 @@ namespace ImGui
159 160
     IMGUI_API bool          Begin(const char* name = "Debug", bool* p_opened = NULL, ImVec2 size = ImVec2(0,0), float fill_alpha = -1.0f, ImGuiWindowFlags flags = 0);// return false when window is collapsed, so you can early out in your code. passing 'bool* p_opened' displays a Close button on the upper-right corner of the window, the pointed value will be set to false when the button is pressed.
160 161
     IMGUI_API void          End();
161 162
     IMGUI_API void          BeginChild(const char* str_id, ImVec2 size = ImVec2(0,0), bool border = false, ImGuiWindowFlags extra_flags = 0);                         // size==0.0f: use remaining window size, size<0.0f: use remaining window size minus abs(size). on each axis.
163
+    IMGUI_API void          BeginChild(ImGuiID id, ImVec2 size = ImVec2(0,0), bool border = false, ImGuiWindowFlags extra_flags = 0);                                 // "
162 164
     IMGUI_API void          EndChild();
163 165
     IMGUI_API bool          GetWindowIsFocused();
164
-    IMGUI_API ImVec2        GetContentRegionMax();                                              // window or current column boundaries
165
-    IMGUI_API ImVec2        GetWindowContentRegionMin();                                        // window boundaries
166
+    IMGUI_API ImVec2        GetContentRegionMax();                                              // window or current column boundaries, in windows coordinates
167
+    IMGUI_API ImVec2        GetWindowContentRegionMin();                                        // window boundaries, in windows coordinates
166 168
     IMGUI_API ImVec2        GetWindowContentRegionMax();
167 169
     IMGUI_API ImDrawList*   GetWindowDrawList();                                                // get rendering command-list if you want to append your own draw primitives.
168 170
     IMGUI_API ImFont*       GetWindowFont();
169
-    IMGUI_API float         GetWindowFontSize();
171
+    IMGUI_API float         GetWindowFontSize();                                                // size (also height in pixels) of current font with current scale applied
170 172
     IMGUI_API void          SetWindowFontScale(float scale);                                    // per-window font scale. Adjust IO.FontGlobalScale if you want to scale all windows.
171 173
     IMGUI_API ImVec2        GetWindowPos();                                                     // you should rarely need/care about the window position, but it can be useful if you want to do your own drawing.
172 174
     IMGUI_API ImVec2        GetWindowSize();                                                    // get current window position.
173 175
     IMGUI_API float         GetWindowWidth();
174 176
     IMGUI_API bool          GetWindowCollapsed();
175
-    IMGUI_API void          SetWindowPos(const ImVec2& pos, ImGuiSetCondition cond = 0);        // set current window position - call within Begin()/End().
176
-    IMGUI_API void          SetWindowSize(const ImVec2& size, ImGuiSetCondition cond = 0);      // set current window size. set to ImVec2(0,0) to force an auto-fit
177
-    IMGUI_API void          SetWindowCollapsed(bool collapsed, ImGuiSetCondition cond = 0);     // set current window collapsed state.
178 177
     IMGUI_API void          SetNextWindowPos(const ImVec2& pos, ImGuiSetCondition cond = 0);    // set next window position - call before Begin().
179
-    IMGUI_API void          SetNextWindowSize(const ImVec2& size, ImGuiSetCondition cond = 0);  // set next window size. set to ImVec2(0,0) to force an auto-fit
178
+    IMGUI_API void          SetNextWindowSize(const ImVec2& size, ImGuiSetCondition cond = 0);  // set next window size. set to ImVec2(0,0) to force an auto-fit.
180 179
     IMGUI_API void          SetNextWindowCollapsed(bool collapsed, ImGuiSetCondition cond = 0); // set next window collapsed state.
180
+    IMGUI_API void          SetWindowPos(const ImVec2& pos, ImGuiSetCondition cond = 0);        // set current window position - call within Begin()/End(). may incur tearing.
181
+    IMGUI_API void          SetWindowSize(const ImVec2& size, ImGuiSetCondition cond = 0);      // set current window size. set to ImVec2(0,0) to force an auto-fit. may incur tearing.
182
+    IMGUI_API void          SetWindowCollapsed(bool collapsed, ImGuiSetCondition cond = 0);     // set current window collapsed state.
181 183
 
182 184
     IMGUI_API void          SetScrollPosHere();                                                 // adjust scrolling position to center into the current cursor position.
183 185
     IMGUI_API void          SetKeyboardFocusHere(int offset = 0);                               // focus keyboard on the next widget. Use positive 'offset' to access sub components of a multiple component widget.
@@ -194,9 +196,9 @@ namespace ImGui
194 196
     IMGUI_API void          PopStyleVar(int count = 1);
195 197
 
196 198
     // Parameters stacks (current window)
197
-    IMGUI_API void          PushItemWidth(float item_width);                                    // width of items for the common item+label case. default to ~2/3 of windows width.
199
+    IMGUI_API void          PushItemWidth(float item_width);                                    // width of items for the common item+label case, pixels. 0.0f = default to ~2/3 of windows width, >0.0f: width in pixels, <0.0f align xx pixels to the right of window (so -0.01f always align width to the right side)
198 200
     IMGUI_API void          PopItemWidth();
199
-    IMGUI_API float         GetItemWidth();
201
+    IMGUI_API float         CalcItemWidth();                                                    // width of item given pushed settings and current cursor position
200 202
     IMGUI_API void          PushAllowKeyboardFocus(bool v);                                     // allow focusing using TAB/Shift-TAB, enabled by default but you can disable it for certain widgets.
201 203
     IMGUI_API void          PopAllowKeyboardFocus();
202 204
     IMGUI_API void          PushTextWrapPos(float wrap_pos_x = 0.0f);                           // word-wrapping for Text*() commands. < 0.0f: no wrapping; 0.0f: wrap to end of window (or column); > 0.0f: wrap at 'wrap_pos_x' position in window local space.
@@ -218,14 +220,16 @@ namespace ImGui
218 220
     IMGUI_API void          SetColumnOffset(int column_index, float offset);
219 221
     IMGUI_API float         GetColumnWidth(int column_index = -1);
220 222
     IMGUI_API ImVec2        GetCursorPos();                                                     // cursor position is relative to window position
223
+    IMGUI_API float         GetCursorPosX();                                                    // "
224
+    IMGUI_API float         GetCursorPosY();                                                    // "
221 225
     IMGUI_API void          SetCursorPos(const ImVec2& pos);                                    // "
222 226
     IMGUI_API void          SetCursorPosX(float x);                                             // "
223 227
     IMGUI_API void          SetCursorPosY(float y);                                             // "
224 228
     IMGUI_API ImVec2        GetCursorScreenPos();                                               // cursor position in absolute screen coordinates (0..io.DisplaySize)
225 229
     IMGUI_API void          SetCursorScreenPos(const ImVec2& pos);                              // cursor position in absolute screen coordinates (0..io.DisplaySize)
226 230
     IMGUI_API void          AlignFirstTextHeightToWidgets();                                    // call once if the first item on the line is a Text() item and you want to vertically lower it to match subsequent (bigger) widgets.
227
-    IMGUI_API float         GetTextLineSpacing();
228
-    IMGUI_API float         GetTextLineHeight();
231
+    IMGUI_API float         GetTextLineHeight();                                                // height of font == GetWindowFontSize()
232
+    IMGUI_API float         GetTextLineHeightWithSpacing();                                     // spacing (in pixels) between 2 consecutive lines of text == GetWindowFontSize() + GetStyle().ItemSpacing.y
229 233
 
230 234
     // ID scopes
231 235
     // If you are creating repeated widgets in a loop you most likely want to push a unique identifier so ImGui can differentiate them.
@@ -253,7 +257,7 @@ namespace ImGui
253 257
     IMGUI_API bool          SmallButton(const char* label);
254 258
     IMGUI_API bool          InvisibleButton(const char* str_id, const ImVec2& size);
255 259
     IMGUI_API void          Image(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0 = ImVec2(0,0), const ImVec2& uv1 = ImVec2(1,1), const ImVec4& tint_col = ImVec4(1,1,1,1), const ImVec4& border_col = ImVec4(0,0,0,0));
256
-    IMGUI_API bool          ImageButton(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0 = ImVec2(0,0),  const ImVec2& uv1 = ImVec2(1,1), int frame_padding = -1, const ImVec4& bg_col = ImVec4(0,0,0,1));    // <0 frame_padding uses default frame padding settings. 0 for no paddnig.
260
+    IMGUI_API bool          ImageButton(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0 = ImVec2(0,0),  const ImVec2& uv1 = ImVec2(1,1), int frame_padding = -1, const ImVec4& bg_col = ImVec4(0,0,0,1), const ImVec4& tint_col = ImVec4(1,1,1,1));    // <0 frame_padding uses default frame padding settings. 0 for no paddnig.
257 261
     IMGUI_API bool          CollapsingHeader(const char* label, const char* str_id = NULL, const bool display_frame = true, const bool default_open = false);
258 262
     IMGUI_API bool          SliderFloat(const char* label, float* v, float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f);     // adjust display_format to decorate the value with a prefix or a suffix. Use power!=1.0 for logarithmic sliders.
259 263
     IMGUI_API bool          SliderFloat2(const char* label, float v[2], float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f);
@@ -272,15 +276,15 @@ namespace ImGui
272 276
     IMGUI_API bool          CheckboxFlags(const char* label, unsigned int* flags, unsigned int flags_value);
273 277
     IMGUI_API bool          RadioButton(const char* label, bool active);
274 278
     IMGUI_API bool          RadioButton(const char* label, int* v, int v_button);
275
-    IMGUI_API bool          InputText(const char* label, char* buf, size_t buf_size, ImGuiInputTextFlags flags = 0, void (*callback)(ImGuiTextEditCallbackData*) = NULL, void* user_data = NULL);
279
+    IMGUI_API bool          InputText(const char* label, char* buf, size_t buf_size, ImGuiInputTextFlags flags = 0, ImGuiTextEditCallback callback = NULL, void* user_data = NULL);
276 280
     IMGUI_API bool          InputFloat(const char* label, float* v, float step = 0.0f, float step_fast = 0.0f, int decimal_precision = -1, ImGuiInputTextFlags extra_flags = 0);
277 281
     IMGUI_API bool          InputFloat2(const char* label, float v[2], int decimal_precision = -1);
278 282
     IMGUI_API bool          InputFloat3(const char* label, float v[3], int decimal_precision = -1);
279 283
     IMGUI_API bool          InputFloat4(const char* label, float v[4], int decimal_precision = -1);
280 284
     IMGUI_API bool          InputInt(const char* label, int* v, int step = 1, int step_fast = 100, ImGuiInputTextFlags extra_flags = 0);
281
-    IMGUI_API bool          Combo(const char* label, int* current_item, const char** items, int items_count, int popup_height_items = 7);
282
-    IMGUI_API bool          Combo(const char* label, int* current_item, const char* items_separated_by_zeros, int popup_height_items = 7);      // separate items with \0, end item-list with \0\0
283
-    IMGUI_API bool          Combo(const char* label, int* current_item, bool (*items_getter)(void* data, int idx, const char** out_text), void* data, int items_count, int popup_height_items = 7);
285
+    IMGUI_API bool          Combo(const char* label, int* current_item, const char** items, int items_count, int height_in_items = -1);
286
+    IMGUI_API bool          Combo(const char* label, int* current_item, const char* items_separated_by_zeros, int height_in_items = -1);      // separate items with \0, end item-list with \0\0
287
+    IMGUI_API bool          Combo(const char* label, int* current_item, bool (*items_getter)(void* data, int idx, const char** out_text), void* data, int items_count, int height_in_items = -1);
284 288
     IMGUI_API bool          ColorButton(const ImVec4& col, bool small_height = false, bool outline_border = true);
285 289
     IMGUI_API bool          ColorEdit3(const char* label, float col[3]);
286 290
     IMGUI_API bool          ColorEdit4(const char* label, float col[4], bool show_alpha = true);
@@ -295,6 +299,15 @@ namespace ImGui
295 299
     IMGUI_API void          TreePop();
296 300
     IMGUI_API void          OpenNextNode(bool open);                                            // force open/close the next TreeNode or CollapsingHeader
297 301
 
302
+    // Selectable / Lists
303
+    IMGUI_API bool          Selectable(const char* label, bool selected, const ImVec2& size = ImVec2(0,0));
304
+    IMGUI_API bool          Selectable(const char* label, bool* p_selected, const ImVec2& size = ImVec2(0,0));
305
+    IMGUI_API bool          ListBox(const char* label, int* current_item, const char** items, int items_count, int height_in_items = -1);
306
+    IMGUI_API bool          ListBox(const char* label, int* current_item, bool (*items_getter)(void* data, int idx, const char** out_text), void* data, int items_count, int height_in_items = -1);
307
+    IMGUI_API bool          ListBoxHeader(const char* label, const ImVec2& size = ImVec2(0,0)); // use if you want to reimplement ListBox() will custom data or interactions. make sure to call ListBoxFooter() afterwards.
308
+    IMGUI_API bool          ListBoxHeader(const char* label, int items_count, int height_in_items = -1); // "
309
+    IMGUI_API void          ListBoxFooter();                                                    // terminate the scrolling region
310
+
298 311
     // Value() Helpers: output single value in "name: value" format. Tip: freely declare your own within the ImGui namespace!
299 312
     IMGUI_API void          Value(const char* prefix, bool b);
300 313
     IMGUI_API void          Value(const char* prefix, int v);
@@ -329,11 +342,20 @@ namespace ImGui
329 342
     IMGUI_API int           GetFrameCount();
330 343
     IMGUI_API const char*   GetStyleColName(ImGuiCol idx);
331 344
     IMGUI_API ImVec2        CalcTextSize(const char* text, const char* text_end = NULL, bool hide_text_after_double_hash = false, float wrap_width = -1.0f);
345
+    IMGUI_API void          CalcListClipping(int items_count, float items_height, int* out_items_display_start, int* out_items_display_end);    // helper to manually clip large list of items. see comments in implementation.
346
+
347
+    IMGUI_API void          BeginChildFrame(ImGuiID id, const ImVec2& size);                    // helper to create a child window / scrolling region that looks like a normal widget frame.
348
+    IMGUI_API void          EndChildFrame();
332 349
 
333 350
     IMGUI_API ImU32         ColorConvertFloat4ToU32(const ImVec4& in);
334 351
     IMGUI_API void          ColorConvertRGBtoHSV(float r, float g, float b, float& out_h, float& out_s, float& out_v);
335 352
     IMGUI_API void          ColorConvertHSVtoRGB(float h, float s, float v, float& out_r, float& out_g, float& out_b);
336 353
 
354
+    // Internal state access - if you want to share ImGui state between modules (e.g. DLL) or allocate it yourself
355
+    IMGUI_API void*         GetInternalState();
356
+    IMGUI_API size_t        GetInternalStateSize();
357
+    IMGUI_API void          SetInternalState(void* state, bool construct = false);
358
+
337 359
     // Obsolete (will be removed)
338 360
     IMGUI_API void          GetDefaultFontData(const void** fnt_data, unsigned int* fnt_size, const void** png_data, unsigned int* png_size);
339 361
 
@@ -366,11 +388,14 @@ enum ImGuiInputTextFlags_
366 388
     // Default: 0
367 389
     ImGuiInputTextFlags_CharsDecimal        = 1 << 0,   // Allow 0123456789.+-*/
368 390
     ImGuiInputTextFlags_CharsHexadecimal    = 1 << 1,   // Allow 0123456789ABCDEFabcdef
369
-    ImGuiInputTextFlags_AutoSelectAll       = 1 << 2,   // Select entire text when first taking focus
370
-    ImGuiInputTextFlags_EnterReturnsTrue    = 1 << 3,   // Return 'true' when Enter is pressed (as opposed to when the value was modified)
371
-    ImGuiInputTextFlags_CallbackCompletion  = 1 << 4,   // Call user function on pressing TAB (for completion handling)
372
-    ImGuiInputTextFlags_CallbackHistory     = 1 << 5,   // Call user function on pressing Up/Down arrows (for history handling)
373
-    ImGuiInputTextFlags_CallbackAlways      = 1 << 6    // Call user function every time
391
+    ImGuiInputTextFlags_CharsUppercase      = 1 << 2,   // Turn a..z into A..Z
392
+    ImGuiInputTextFlags_CharsNoBlank        = 1 << 3,   // Filter out spaces, tabs
393
+    ImGuiInputTextFlags_AutoSelectAll       = 1 << 4,   // Select entire text when first taking focus
394
+    ImGuiInputTextFlags_EnterReturnsTrue    = 1 << 5,   // Return 'true' when Enter is pressed (as opposed to when the value was modified)
395
+    ImGuiInputTextFlags_CallbackCompletion  = 1 << 6,   // Call user function on pressing TAB (for completion handling)
396
+    ImGuiInputTextFlags_CallbackHistory     = 1 << 7,   // Call user function on pressing Up/Down arrows (for history handling)
397
+    ImGuiInputTextFlags_CallbackAlways      = 1 << 8,   // Call user function every time
398
+    ImGuiInputTextFlags_CallbackCharFilter  = 1 << 9    // Call user function to filter character. Modify data->EventChar to replace/filter input, or return 1 to discard character.
374 399
     //ImGuiInputTextFlags_AlignCenter       = 1 << 6,
375 400
 };
376 401
 
@@ -402,6 +427,7 @@ enum ImGuiCol_
402 427
 {
403 428
     ImGuiCol_Text,
404 429
     ImGuiCol_WindowBg,
430
+    ImGuiCol_ChildWindowBg,
405 431
     ImGuiCol_Border,
406 432
     ImGuiCol_BorderShadow,
407 433
     ImGuiCol_FrameBg,               // Background of checkbox, radio button, plot, slider, text input
@@ -445,14 +471,15 @@ enum ImGuiCol_
445 471
 // NB: the enum only refers to fields of ImGuiStyle() which makes sense to be pushed/poped in UI code. Feel free to add others.
446 472
 enum ImGuiStyleVar_
447 473
 {
448
-    ImGuiStyleVar_Alpha,             // float
449
-    ImGuiStyleVar_WindowPadding,     // ImVec2
450
-    ImGuiStyleVar_WindowRounding,    // float
451
-    ImGuiStyleVar_FramePadding,      // ImVec2
452
-    ImGuiStyleVar_FrameRounding,     // float
453
-    ImGuiStyleVar_ItemSpacing,       // ImVec2
454
-    ImGuiStyleVar_ItemInnerSpacing,  // ImVec2
455
-    ImGuiStyleVar_TreeNodeSpacing    // float
474
+    ImGuiStyleVar_Alpha,               // float
475
+    ImGuiStyleVar_WindowPadding,       // ImVec2
476
+    ImGuiStyleVar_WindowRounding,      // float
477
+    ImGuiStyleVar_ChildWindowRounding, // float
478
+    ImGuiStyleVar_FramePadding,        // ImVec2
479
+    ImGuiStyleVar_FrameRounding,       // float
480
+    ImGuiStyleVar_ItemSpacing,         // ImVec2
481
+    ImGuiStyleVar_ItemInnerSpacing,    // ImVec2
482
+    ImGuiStyleVar_TreeNodeSpacing      // float
456 483
 };
457 484
 
458 485
 // Enumeration for ColorEditMode()
@@ -480,6 +507,7 @@ struct ImGuiStyle
480 507
     ImVec2      WindowPadding;              // Padding within a window
481 508
     ImVec2      WindowMinSize;              // Minimum window size
482 509
     float       WindowRounding;             // Radius of window corners rounding. Set to 0.0f to have rectangular windows
510
+    float       ChildWindowRounding;        // Radius of child window corners rounding. Set to 0.0f to have rectangular windows
483 511
     ImVec2      FramePadding;               // Padding within a framed rectangle (used by most widgets)
484 512
     float       FrameRounding;              // Radius of frame corners rounding. Set to 0.0f to have rectangular frame (used by most widgets).
485 513
     ImVec2      ItemSpacing;                // Horizontal and vertical spacing between widgets/lines
@@ -561,6 +589,7 @@ struct ImGuiIO
561 589
 
562 590
     bool        WantCaptureMouse;           // Mouse is hovering a window or widget is active (= ImGui will use your mouse input)
563 591
     bool        WantCaptureKeyboard;        // Widget is active (= ImGui will use your keyboard input)
592
+    float       Framerate;                  // Framerate estimation, in frame per second. Rolling average estimation based on IO.DeltaTime over 120 frames
564 593
 
565 594
     //------------------------------------------------------------------
566 595
     // [Internal] ImGui will maintain those fields for you
@@ -692,15 +721,21 @@ struct ImGuiStorage
692 721
 // Shared state of InputText(), passed to callback when a ImGuiInputTextFlags_Callback* flag is used.
693 722
 struct ImGuiTextEditCallbackData
694 723
 {
695
-    ImGuiKey            EventKey;       // Key pressed (Up/Down/TAB)        // Read-only    
696
-    char*               Buf;            // Current text                     // Read-write (pointed data only)
697
-    size_t              BufSize;        //                                  // Read-only
698
-    bool                BufDirty;       // Set if you modify Buf directly   // Write
699
-    ImGuiInputTextFlags Flags;          // What user passed to InputText()  // Read-only
700
-    int                 CursorPos;      //                                  // Read-write
701
-    int                 SelectionStart; //                                  // Read-write (== to SelectionEnd when no selection)
702
-    int                 SelectionEnd;   //                                  // Read-write
703
-    void*               UserData;       // What user passed to InputText()
724
+    ImGuiInputTextFlags EventFlag;      // One of ImGuiInputTextFlags_Callback* // Read-only
725
+    ImGuiInputTextFlags Flags;          // What user passed to InputText()      // Read-only
726
+    void*               UserData;       // What user passed to InputText()      // Read-only
727
+
728
+    // CharFilter event:
729
+    ImWchar             EventChar;      // Character input                      // Read-write (replace character or set to zero)
730
+
731
+    // Completion,History,Always events:
732
+    ImGuiKey            EventKey;       // Key pressed (Up/Down/TAB)            // Read-only
733
+    char*               Buf;            // Current text                         // Read-write (pointed data only)
734
+    size_t              BufSize;        //                                      // Read-only
735
+    bool                BufDirty;       // Set if you modify Buf directly       // Write
736
+    int                 CursorPos;      //                                      // Read-write
737
+    int                 SelectionStart; //                                      // Read-write (== to SelectionEnd when no selection)
738
+    int                 SelectionEnd;   //                                      // Read-write
704 739
 
705 740
     // NB: calling those function loses selection.
706 741
     void DeleteChars(int pos, int bytes_count);
@@ -796,7 +831,7 @@ struct ImDrawList
796 831
     IMGUI_API void  AddCircle(const ImVec2& centre, float radius, ImU32 col, int num_segments = 12);
797 832
     IMGUI_API void  AddCircleFilled(const ImVec2& centre, float radius, ImU32 col, int num_segments = 12);
798 833
     IMGUI_API void  AddArc(const ImVec2& center, float rad, ImU32 col, int a_min, int a_max, bool tris = false, const ImVec2& third_point_offset = ImVec2(0,0));
799
-    IMGUI_API void  AddText(ImFont* font, float font_size, const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end = NULL, float wrap_width = 0.0f);
834
+    IMGUI_API void  AddText(ImFont* font, float font_size, const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end = NULL, float wrap_width = 0.0f, const ImVec2* cpu_clip_max = NULL);
800 835
     IMGUI_API void  AddImage(ImTextureID user_texture_id, const ImVec2& a, const ImVec2& b, const ImVec2& uv0, const ImVec2& uv1, ImU32 col = 0xFFFFFFFF);
801 836
 
802 837
     // Advanced
@@ -886,6 +921,7 @@ struct ImFont
886 921
     };
887 922
     ImFontAtlas*        ContainerAtlas;     // What we has been loaded into
888 923
     ImVector<Glyph>     Glyphs;
924
+    ImVector<float>     IndexXAdvance;      // Glyphs->XAdvance directly indexable (for CalcTextSize functions which are often bottleneck in large UI)
889 925
     ImVector<int>       IndexLookup;        // Index glyphs by Unicode code-point
890 926
     const Glyph*        FallbackGlyph;      // == FindGlyph(FontFallbackChar)
891 927
 
@@ -901,7 +937,7 @@ struct ImFont
901 937
     // 'wrap_width' enable automatic word-wrapping across multiple lines to fit into given width. 0.0f to disable.
902 938
     IMGUI_API ImVec2                CalcTextSizeA(float size, float max_width, float wrap_width, const char* text_begin, const char* text_end = NULL, const char** remaining = NULL) const; // utf8
903 939
     IMGUI_API ImVec2                CalcTextSizeW(float size, float max_width, const ImWchar* text_begin, const ImWchar* text_end, const ImWchar** remaining = NULL) const;                 // wchar
904
-    IMGUI_API void                  RenderText(float size, ImVec2 pos, ImU32 col, const ImVec4& clip_rect, const char* text_begin, const char* text_end, ImDrawVert*& out_vertices, float wrap_width = 0.0f) const;
940
+    IMGUI_API void                  RenderText(float size, ImVec2 pos, ImU32 col, const ImVec4& clip_rect, const char* text_begin, const char* text_end, ImDrawVert*& out_vertices, float wrap_width = 0.0f, const ImVec2* cpu_clip_max = NULL) const;
905 941
     IMGUI_API const char*           CalcWordWrapPositionA(float scale, const char* text, const char* text_end, float wrap_width) const;
906 942
 };
907 943
 

+ 2
- 2
src/system/FontImGui.cpp Wyświetl plik

@@ -18,7 +18,7 @@ unsigned int FontImGui::widthText(float scale, std::string s) {
18 18
     ImGuiIO& io = ImGui::GetIO();
19 19
     ImFont* font = io.Fonts->Fonts.at(0);
20 20
     ImVec2 size = font->CalcTextSizeA(scale * SCALE_CALC, FLT_MAX, io.DisplaySize.y, s.c_str(),
21
-                                                    s.c_str() + s.length());
21
+                                      s.c_str() + s.length());
22 22
     return size.x;
23 23
 }
24 24
 
@@ -42,7 +42,7 @@ unsigned int FontImGui::heightText(float scale, unsigned int maxWidth, std::stri
42 42
     ImGuiIO& io = ImGui::GetIO();
43 43
     ImFont* font = io.Fonts->Fonts.at(0);
44 44
     ImVec2 size = font->CalcTextSizeA(scale * SCALE_CALC, FLT_MAX, maxWidth, s.c_str(),
45
-                                                    s.c_str() + s.length());
45
+                                      s.c_str() + s.length());
46 46
     return size.y;
47 47
 }
48 48
 

+ 6
- 3
src/system/Shader.cpp Wyświetl plik

@@ -240,8 +240,9 @@ void Shader::drawGL(ShaderBuffer& vertices, ShaderBuffer& uvs, glm::vec4 color,
240 240
                     unsigned int texture, TextureStorage store, unsigned int mode,
241 241
                     Shader& shader) {
242 242
     assert(vertices.getSize() == uvs.getSize());
243
-    if (mode == GL_TRIANGLES)
243
+    if (mode == GL_TRIANGLES) {
244 244
         assert((vertices.getSize() % 3) == 0)
245
+    }
245 246
 
246 247
     shader.use();
247 248
     shader.loadUniform(0, Window::getSize());
@@ -293,8 +294,9 @@ void Shader::drawGL(ShaderBuffer& vertices, ShaderBuffer& uvs, ShaderBuffer& ind
293 294
 void Shader::drawGL(ShaderBuffer& vertices, ShaderBuffer& colors, glm::mat4 MVP,
294 295
                     unsigned int mode, Shader& shader) {
295 296
     assert(vertices.getSize() == colors.getSize());
296
-    if (mode == GL_TRIANGLES)
297
+    if (mode == GL_TRIANGLES) {
297 298
         assert((vertices.getSize() % 3) == 0)
299
+    }
298 300
 
299 301
     shader.use();
300 302
     shader.loadUniform(0, MVP);
@@ -308,8 +310,9 @@ void Shader::drawGL(ShaderBuffer& vertices, ShaderBuffer& colors, glm::mat4 MVP,
308 310
 void Shader::drawGL(ShaderBuffer& vertices, ShaderBuffer& colors, ShaderBuffer& indices,
309 311
                     glm::mat4 MVP, unsigned int mode, Shader& shader) {
310 312
     assert(vertices.getSize() == colors.getSize());
311
-    if (mode == GL_TRIANGLES)
313
+    if (mode == GL_TRIANGLES) {
312 314
         assert((indices.getSize() % 3) == 0)
315
+    }
313 316
 
314 317
     shader.use();
315 318
     shader.loadUniform(0, MVP);

+ 15
- 0
src/system/WindowSDL.cpp Wyświetl plik

@@ -74,6 +74,21 @@ int WindowSDL::initialize() {
74 74
         return 0;
75 75
     }
76 76
 
77
+    SDL_GameControllerAddMapping("341a0000000000000208000000000000,"
78
+                                 "USB GAMEPAD 8116,"
79
+                                 "a:b0,x:b2,start:b7,back:b6,leftstick:b8,rightstick:b9,"
80
+                                 "leftshoulder:b4,rightshoulder:b5,"
81
+                                 "dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,"
82
+                                 "leftx:a0,lefty:a1,rightx:a3,righty:a2,"
83
+                                 "lefttrigger:,b:b1,y:b3,lefttrigger:a4,righttrigger:a4");
84
+
85
+    SDL_GameControllerAddMapping("10080000000000000100000000000000,"
86
+                                 "Twin USB Joystick,"
87
+                                 "a:b4,b:b2,y:b0,x:b6,start:b18,back:b16,leftstick:b20,"
88
+                                 "rightstick:b22,leftshoulder:b12,rightshoulder:b14,dpup:h0.1,"
89
+                                 "dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a2,rightx:a6,"
90
+                                 "righty:a4,lefttrigger:b8,righttrigger:b10");
91
+
77 92
     for (int i = 0; i < SDL_NumJoysticks(); i++) {
78 93
         if (SDL_IsGameController(i)) {
79 94
             controller = SDL_GameControllerOpen(i);

Ładowanie…
Anuluj
Zapisz