]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Reformat code
authorotta8634 <k9wolf@pm.me>
Mon, 16 Dec 2024 09:58:22 +0000 (17:58 +0800)
committerotta8634 <k9wolf@pm.me>
Mon, 16 Dec 2024 09:58:22 +0000 (17:58 +0800)
It looked too crammed before.
Used mostly Allman style as per CONTRIBUTING.md.

qcsrc/menu/xonotic/dialog_multiplayer_media_guide.qc
qcsrc/menu/xonotic/guide/description.qh
qcsrc/menu/xonotic/guide/entries.qc
qcsrc/menu/xonotic/guide/guide.qh
qcsrc/menu/xonotic/guide/topics.qc

index 4ff36c5f6d00647a3bfdb3d24637624958096735..c65e5682298aab64e6a60b938846268cc4e5e0ab 100644 (file)
@@ -51,8 +51,16 @@ void XonoticGuideTab_topicChangeNotify(entity, entity this)
        int i = topics.selectedItem;
        int idx = 0;
        entity found = NULL;
-       #define TOPIC(src, name, icon) if (idx++ == i) { static entity e; if (!e) e = src; found = e; break; }
-       do { TOPICS(TOPIC); } while (0);
+       #define TOPIC(src, name, icon) \
+               if (idx++ == i) \
+               { \
+                       static entity e; \
+                       if (!e) e = src; \
+                       found = e; \
+                       break; \
+               }
+       do { TOPICS(TOPIC); }
+       while (0);
        #undef TOPIC
        entries.source = found;
        entries.refilter(entries);
@@ -65,6 +73,7 @@ void XonoticGuideTab_entryChangeNotify(entity, entity this)
        entity entries = this.entryList;
        entity e = entries.source.getEntry(entries.source, entries.selectedItem, func_null);
        string s = e.describe(e);
-       if (cvar("developer")) { s = sprintf("entity %i\n%s", e, s); }
+       if (cvar("developer"))
+               s = sprintf("entity %i\n%s", e, s);
        desc.setDescription(desc, s);
 }
index a4c2033839bda5e7535dc0effd945a00a18732f4..a7f1501090a3aadb2d6df615abf707955c109c70 100644 (file)
@@ -27,17 +27,21 @@ CLASS(XonoticGuideDescription, XonoticListBox)
        void XonoticGuideDescription_setDescription(entity this, string desc)
        {
                string current = this.description;
-               if (current && current != desc) strunzone(current);
+               if (current && current != desc)
+                       strunzone(current);
                this.description = strzone(desc);
 
                string currentWrapped = this.descriptionWrapped;
-               if (currentWrapped) strunzone(currentWrapped);
+               if (currentWrapped)
+                       strunzone(currentWrapped);
                string wrapped = "";
-               for (int i = 0, n = tokenizebyseparator(desc, "\n"); i < n; ++i) {
+               for (int i = 0, n = tokenizebyseparator(desc, "\n"); i < n; ++i)
+               {
                        string line = "";
-                       for (getWrappedLine_remaining = argv(i); getWrappedLine_remaining; ) {
+                       for (getWrappedLine_remaining = argv(i); getWrappedLine_remaining; )
+                       {
                                string s = getWrappedLine(1, this.realFontSize, draw_TextWidth_WithColors);
-                               line = sprintf("%s\n%s", line, s);
+                               line = strcat(line, "\n", s);
                        }
                        wrapped = strcat(wrapped, line);
                }
index a5430314d9b72dc09bf422d9176cd09f3e17a084..f09210db876fa0e46ecaf14018915e9613ed9ce1 100644 (file)
@@ -16,18 +16,22 @@ void XonoticEntryList_drawListBoxItem(entity this, int i, vector absSize, bool i
        if (!this.source.getEntry(this.source, i, XonoticEntryList_cb)) return;
        string name = XonoticEntryList_cb_name;
        string icon = XonoticEntryList_cb_icon;
-       if (isSelected) {
+       if (isSelected)
                draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_SELECTED, SKINALPHA_LISTBOX_SELECTED);
-       } else if (isFocused) {
+       else if (isFocused)
+       {
                this.focusedItemAlpha = getFadedAlpha(this.focusedItemAlpha, SKINALPHA_LISTBOX_FOCUSED, SKINFADEALPHA_LISTBOX_FOCUSED);
                draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_FOCUSED, this.focusedItemAlpha);
        }
        vector sz = draw_PictureSize(icon);
-       if (!sz) sz = '1 1 0';
+       if (!sz)
+               sz = '1 1 0';
        float szr = sz.x / sz.y;
-       if (strstrofs(icon, "map", 0) >= 0) szr = 4 / 3;
+       if (strstrofs(icon, "map", 0) >= 0)
+               szr = 4 / 3;
        float asr = this.itemAbsSize.x / this.itemAbsSize.y;
-       sz.y = 1; sz.x = szr / asr;
+       sz.y = 1;
+       sz.x = szr / asr;
        draw_Picture('0 0 0', icon, sz, '1 1 1', SKINALPHA_LISTBOX_SELECTED);
        string s = draw_TextShortenToWidth(strdecolorize(name), 1 - sz.x - 2 * this.realFontSize.x, 0, this.realFontSize);
        draw_Text(this.realUpperMargin1 * eY + (sz.x + 0.5 * this.realFontSize.x) * eX, s, this.realFontSize, '1 1 1', SKINALPHA_TEXT, 0);
@@ -35,28 +39,36 @@ void XonoticEntryList_drawListBoxItem(entity this, int i, vector absSize, bool i
 
 METHOD(XonoticEntryList, keyDown, float(entity this, float scan, float ascii, float shift))
 {
-       if (this.nItems <= 0) {
+       if (this.nItems <= 0)
                return SUPER(XonoticEntryList).keyDown(this, scan, ascii, shift);
-       } else if ((ascii >= 32 || scan == K_BACKSPACE) && this.source.indexOf) {
+       else if ((ascii >= 32 || scan == K_BACKSPACE) && this.source.indexOf)
+       {
                string save;
-               if (scan == K_BACKSPACE) {
+               if (scan == K_BACKSPACE)
                        save = substring(this.typeToSearchString, 0, strlen(this.typeToSearchString) - 1);
-               } else {
+               else
+               {
                        string ch = chr(ascii);
                        save = (time > this.typeToSearchTime) ? ch : strcat(this.typeToSearchString, ch);
                }
-               if (this.typeToSearchString) strunzone(this.typeToSearchString);
+               if (this.typeToSearchString)
+                       strunzone(this.typeToSearchString);
                this.typeToSearchString = strzone(save);
                this.typeToSearchTime = time + 0.5;
-               if (strlen(this.typeToSearchString)) {
+               if (strlen(this.typeToSearchString))
+               {
                        int idx = this.source.indexOf(this.source, this.typeToSearchString);
-                       if (idx >= 0) this.setSelected(this, idx);
+                       if (idx >= 0)
+                               this.setSelected(this, idx);
                }
-       } else if (shift & S_CTRL && scan == 'f') {
+       }
+       else if (shift & S_CTRL && scan == 'f')
                this.parent.setFocus(this.parent, this.stringFilterBox);
-       } else if (shift & S_CTRL && scan == 'u') {
+       else if (shift & S_CTRL && scan == 'u')
+       {
                this.stringFilterBox.setText(this.stringFilterBox, "");
-               if (this.stringFilter) strunzone(this.stringFilter);
+               if (this.stringFilter)
+                       strunzone(this.stringFilter);
                this.stringFilter = string_null;
                this.refilter(this);
        }
@@ -65,16 +77,15 @@ METHOD(XonoticEntryList, keyDown, float(entity this, float scan, float ascii, fl
 
 void XonoticEntryList_refilter(entity this)
 {
-       if (!this.source) {
+       if (!this.source)
+       {
                this.nItems = 0;
                return;
        }
        this.nItems = this.source.reload(this.source, this.stringFilter);
-       for (int i = 0, n = this.nItems; i < n; ++i) {
-               if (this.source.getEntry(this.source, i, XonoticEntryList_cb)) {
+       for (int i = 0, n = this.nItems; i < n; ++i)
+               if (this.source.getEntry(this.source, i, XonoticEntryList_cb))
                        draw_PreloadPicture(XonoticEntryList_cb_icon);
-               }
-       }
 }
 
 void XonoticEntryList_resizeNotify(entity this, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
index de9257a2ea0c07f3999f0d1f34ff31ecc20108ca..2bf2aa55618afd634faaf4f5e976d750e865ffe0 100644 (file)
 CLASS(TopicSource, DataSource)
        METHOD(TopicSource, getEntry, entity(TopicSource this, int i, void(string, string) returns)) {
                int idx = 0;
-               #define TOPIC(src, name, icon) if (idx++ == i) { if (returns) returns(name, icon); return DataSource_true; }
+               #define TOPIC(src, name, icon) \
+                       if (idx++ == i) \
+                       { \
+                               if (returns) \
+                                       returns(name, icon); \
+                               return DataSource_true; \
+                       }
                TOPICS(TOPIC);
                #undef TOPIC
-               if (returns) returns("undefined", "undefined");
+               if (returns)
+                       returns("undefined", "undefined");
                return DataSource_false;
        }
        METHOD(TopicSource, reload, int(TopicSource this, string filter)) {
@@ -48,9 +55,10 @@ CLASS(DebugSource, DataSource)
                        if (it.instanceOfDataSource) continue;
                        if (it.classname == "Object") continue;
                        if (it.classname == "vtbl") continue;
-                       if (!tail) {
+                       if (!tail)
                                tail = head = it;
-                       } else {
+                       else
+                       {
                                tail.nextdebug = it;
                                tail = it;
                        }
@@ -61,18 +69,21 @@ CLASS(DebugSource, DataSource)
        METHOD(DebugSource, getEntry, entity(DebugSource this, int i, void(string, string) returns)) {
                int idx = 0;
                entity e;
-               for (e = find_debug(); e; e = e.nextdebug) {
+               for (e = find_debug(); e; e = e.nextdebug)
+               {
                        if (strstrofs(sprintf("entity %i", e), DebugSource_activeFilter, 0) < 0) continue;
                        if (idx++ == i) break;
                }
-               if (returns) e.display(e, returns);
+               if (returns)
+                       e.display(e, returns);
                return e;
        }
        METHOD(DebugSource, reload, int(DebugSource this, string filter)) {
                DebugSource_activeFilter = filter;
                int idx = 0;
                entity e;
-               for (e = find_debug(); e; e = e.nextdebug) {
+               for (e = find_debug(); e; e = e.nextdebug)
+               {
                        if (strstrofs(sprintf("entity %i", e), DebugSource_activeFilter, 0) < 0) continue;
                        idx++;
                }
@@ -96,7 +107,8 @@ STATIC_INIT_LATE(arr##_MENU) \
 CLASS(id, DataSource) \
        METHOD(id, getEntry, entity(id this, int i, void(string, string) returns)) { \
                entity e = AL_gete(arr##_MENU, i); \
-               if (returns) e.display(e, returns); \
+               if (returns) \
+                       e.display(e, returns); \
                return e; \
        } \
        METHOD(id, reload, int(id this, string filter)) { return arr##_MENU_COUNT; } \
@@ -133,10 +145,12 @@ REGISTRY_SOURCE(MutatorSource, Mutators)
 
 CLASS(MapSource, DataSource)
        METHOD(MapSource, getEntry, entity(MapSource this, int i, void(string, string) returns)) {
-               if (!MapInfo_Get_ByID(i)) return DataSource_false;
+               if (!MapInfo_Get_ByID(i))
+                       return DataSource_false;
                string path = strcat("/maps/", MapInfo_Map_bspname);
                string img = draw_PictureSize(path) ? path : "nopreview_map";
-               if (returns) returns(MapInfo_Map_titlestring, img);
+               if (returns)
+                       returns(MapInfo_Map_titlestring, img);
                MapInfo_ClearTemps();
                return DataSource_true;
        }
@@ -146,7 +160,8 @@ CLASS(MapSource, DataSource)
        }
        METHOD(MapSource, reload, int(MapSource this, string s)) {
                _MapInfo_FilterGametype(MAPINFO_TYPE_ALL, 0, 0, 0, 0);
-               if (s) MapInfo_FilterString(s);
+               if (s)
+                       MapInfo_FilterString(s);
                return MapInfo_count;
        }
        METHOD(MapSource, destroy, void(MapSource this)) { MapInfo_Shutdown(); }
index 9d1453dce10386480f354b77ad9f1b561fbefea2..0e693dc948c916b11d318e20446c7dc67c30a8f6 100644 (file)
@@ -19,9 +19,10 @@ void XonoticTopicList_drawListBoxItem(entity this, int i, vector absSize, bool i
        if (!this.source.getEntry(this.source, i, XonoticTopicList_cb)) return;
        string icon = XonoticTopicList_cb_icon;
        string name = XonoticTopicList_cb_name;
-       if (isSelected) {
+       if (isSelected)
                draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_SELECTED, SKINALPHA_LISTBOX_SELECTED);
-       } else if (isFocused) {
+       else if (isFocused)
+       {
                this.focusedItemAlpha = getFadedAlpha(this.focusedItemAlpha, SKINALPHA_LISTBOX_FOCUSED, SKINFADEALPHA_LISTBOX_FOCUSED);
                draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_FOCUSED, this.focusedItemAlpha);
        }
@@ -37,7 +38,8 @@ void XonoticTopicList_drawListBoxItem(entity this, int i, vector absSize, bool i
 
 bool XonoticTopicList_keyDown(entity this, float scan, float ascii, float shift)
 {
-       if (scan == K_ENTER || scan == K_KP_ENTER) {
+       if (scan == K_ENTER || scan == K_KP_ENTER)
+       {
                m_play_click_sound(MENU_SOUND_EXECUTE);
                return true;
        }