Differences From Artifact [8be4b9144c]:
- File src/menus.mm — part of check-in [fa4b03aaca] at 2025-03-08 00:48:42 on branch trunk — Migrate more strings (user: js, size: 3195) [annotate] [blame] [check-ins using]
To Artifact [e754271834]:
- File
src/menus.mm
— part of check-in
[489124a92f]
at
2025-03-16 10:11:39
on branch trunk
— Use one autorelease pool per frame
This way, nowhere else autorelease pools need to be managed. (user: js, size: 3087) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
39 40 41 42 43 44 45 | } void refreshservers(); bool rendermenu() { | < | | | | | | | | | < | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | < | 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | } void refreshservers(); bool rendermenu() { if (vmenu < 0) { [menuStack removeAllObjects]; return false; } if (vmenu == 1) refreshservers(); Menu *m = menus[vmenu]; OFString *title; if (vmenu > 1) title = [OFString stringWithFormat:@"[ %@ menu ]", m.name]; else title = m.name; int mdisp = m.items.count; int w = 0; loopi(mdisp) { int x = text_width(m.items[i].text); if (x > w) w = x; } int tw = text_width(title); if (tw > w) w = tw; int step = FONTH / 4 * 5; int h = (mdisp + 2) * step; int y = (VIRTH - h) / 2; int x = (VIRTW - w) / 2; blendbox(x - FONTH / 2 * 3, y - FONTH, x + w + FONTH / 2 * 3, y + h + FONTH, true); draw_text(title, x, y, 2); y += FONTH * 2; if (vmenu) { int bh = y + m.menusel * step; blendbox( x - FONTH, bh - 10, x + w + FONTH, bh + FONTH + 10, false); } loopj(mdisp) { draw_text(m.items[j].text, x, y, 2); y += step; } return true; } void newmenu(OFString *name) { if (menus == nil) menus = [[OFMutableArray alloc] init]; |
︙ | ︙ | |||
150 151 152 153 154 155 156 | menusel = n - 1; else if (menusel >= n) menusel = 0; menus[vmenu].menusel = menusel; } else { if (code == SDLK_RETURN || code == -2) { OFString *action = menus[vmenu].items[menusel].action; | | < | < < | 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 | menusel = n - 1; else if (menusel >= n) menusel = 0; menus[vmenu].menusel = menusel; } else { if (code == SDLK_RETURN || code == -2) { OFString *action = menus[vmenu].items[menusel].action; if (vmenu == 1) connects(getservername(menusel)); if (menuStack == nil) menuStack = [[OFMutableArray alloc] init]; [menuStack addObject:@(vmenu)]; menuset(-1); execute(action, true); } } return true; } |