It looked too crammed before.
Used mostly Allman style as per CONTRIBUTING.md.
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);
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);
}
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);
}
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);
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);
}
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)
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)) {
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;
}
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++;
}
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; } \
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;
}
}
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(); }
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);
}
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;
}