802 */ |
802 */ |
803 bool InsertTextBufferChar(Textbuf *tb, byte key) |
803 bool InsertTextBufferChar(Textbuf *tb, byte key) |
804 { |
804 { |
805 const byte charwidth = GetCharacterWidth(key); |
805 const byte charwidth = GetCharacterWidth(key); |
806 if (tb->length < tb->maxlength && (tb->maxwidth == 0 || tb->width + charwidth <= tb->maxwidth)) { |
806 if (tb->length < tb->maxlength && (tb->maxwidth == 0 || tb->width + charwidth <= tb->maxwidth)) { |
807 memmove(tb->buf + tb->caretpos + 1, tb->buf + tb->caretpos, tb->length - tb->caretpos); |
807 memmove(tb->buf + tb->caretpos + 1, tb->buf + tb->caretpos, (tb->length - tb->caretpos) + 1); |
808 tb->buf[tb->caretpos] = key; |
808 tb->buf[tb->caretpos] = key; |
809 tb->length++; |
809 tb->length++; |
810 tb->width += charwidth; |
810 tb->width += charwidth; |
811 |
811 |
812 tb->caretpos++; |
812 tb->caretpos++; |
1007 e.event = WE_ON_EDIT_TEXT_CANCEL; |
1006 e.event = WE_ON_EDIT_TEXT_CANCEL; |
1008 parent->wndproc(parent, &e); |
1007 parent->wndproc(parent, &e); |
1009 } |
1008 } |
1010 } |
1009 } |
1011 _query_string_active = false; |
1010 _query_string_active = false; |
1012 _editbox_win = NULL; |
1011 CLRBIT(_no_scroll, SCROLL_EDIT); |
1013 break; |
1012 break; |
1014 } |
1013 } |
1015 } |
1014 } |
1016 |
1015 |
1017 static const Widget _query_string_widgets[] = { |
1016 static const Widget _query_string_widgets[] = { |
1044 |
1043 |
1045 DeleteWindowById(WC_QUERY_STRING, 0); |
1044 DeleteWindowById(WC_QUERY_STRING, 0); |
1046 DeleteWindowById(WC_SAVELOAD, 0); |
1045 DeleteWindowById(WC_SAVELOAD, 0); |
1047 |
1046 |
1048 w = AllocateWindowDesc(&_query_string_desc); |
1047 w = AllocateWindowDesc(&_query_string_desc); |
|
1048 SETBIT(_no_scroll, SCROLL_EDIT); |
1049 |
1049 |
1050 GetString(_edit_str_buf, str); |
1050 GetString(_edit_str_buf, str); |
1051 _edit_str_buf[realmaxlen] = '\0'; |
1051 _edit_str_buf[realmaxlen] = '\0'; |
1052 |
1052 |
1053 if (maxlen & 0x1000) { |
1053 if (maxlen & 0x1000) { |
1301 case WE_TIMEOUT: |
1301 case WE_TIMEOUT: |
1302 if (HASBIT(w->click_state, 10)) { /* Delete button clicked */ |
1302 if (HASBIT(w->click_state, 10)) { /* Delete button clicked */ |
1303 FiosDelete(WP(w,querystr_d).text.buf); |
1303 FiosDelete(WP(w,querystr_d).text.buf); |
1304 SetWindowDirty(w); |
1304 SetWindowDirty(w); |
1305 BuildFileList(); |
1305 BuildFileList(); |
1306 if (_saveload_mode == SLD_SAVE_GAME) |
1306 if (_saveload_mode == SLD_SAVE_GAME) { |
1307 GenerateFileName(); /* Reset file name to current date */ |
1307 GenerateFileName(); /* Reset file name to current date */ |
|
1308 UpdateTextBufferSize(&WP(w, querystr_d).text); |
|
1309 } |
1308 } else if (HASBIT(w->click_state, 11)) { /* Save button clicked */ |
1310 } else if (HASBIT(w->click_state, 11)) { /* Save button clicked */ |
1309 _switch_mode = SM_SAVE; |
1311 _switch_mode = SM_SAVE; |
1310 FiosMakeSavegameName(_file_to_saveload.name, WP(w,querystr_d).text.buf); |
1312 FiosMakeSavegameName(_file_to_saveload.name, WP(w,querystr_d).text.buf); |
1311 |
1313 |
1312 /* In the editor set up the vehicle engines correctly (date might have changed) */ |
1314 /* In the editor set up the vehicle engines correctly (date might have changed) */ |
1317 // pause is only used in single-player, non-editor mode, non menu mode |
1319 // pause is only used in single-player, non-editor mode, non menu mode |
1318 if(!_networking && (_game_mode != GM_EDITOR) && (_game_mode != GM_MENU)) |
1320 if(!_networking && (_game_mode != GM_EDITOR) && (_game_mode != GM_MENU)) |
1319 DoCommandP(0, 0, 0, NULL, CMD_PAUSE); |
1321 DoCommandP(0, 0, 0, NULL, CMD_PAUSE); |
1320 _query_string_active = false; |
1322 _query_string_active = false; |
1321 FiosFreeSavegameList(); |
1323 FiosFreeSavegameList(); |
|
1324 CLRBIT(_no_scroll, SCROLL_SAVE); |
1322 break; |
1325 break; |
1323 case WE_RESIZE: { |
1326 case WE_RESIZE: { |
1324 /* Widget 2 and 3 have to go with halve speed, make it so obiwan */ |
1327 /* Widget 2 and 3 have to go with halve speed, make it so obiwan */ |
1325 uint diff = e->sizing.diff.x / 2; |
1328 uint diff = e->sizing.diff.x / 2; |
1326 w->widget[2].right += diff; |
1329 w->widget[2].right += diff; |
1385 SetObjectToPlace(1, 0, 0, 0); |
1388 SetObjectToPlace(1, 0, 0, 0); |
1386 DeleteWindowById(WC_QUERY_STRING, 0); |
1389 DeleteWindowById(WC_QUERY_STRING, 0); |
1387 DeleteWindowById(WC_SAVELOAD, 0); |
1390 DeleteWindowById(WC_SAVELOAD, 0); |
1388 |
1391 |
1389 _saveload_mode = mode; |
1392 _saveload_mode = mode; |
|
1393 SETBIT(_no_scroll, SCROLL_SAVE); |
|
1394 |
|
1395 switch (mode) { |
|
1396 case SLD_SAVE_GAME: |
|
1397 GenerateFileName(); |
|
1398 break; |
|
1399 case SLD_SAVE_SCENARIO: |
|
1400 strcpy(_edit_str_buf, "UNNAMED"); |
|
1401 break; |
|
1402 } |
1390 |
1403 |
1391 w = AllocateWindowDesc(_saveload_dialogs[mode]); |
1404 w = AllocateWindowDesc(_saveload_dialogs[mode]); |
1392 w->vscroll.cap = 24; |
1405 w->vscroll.cap = 24; |
1393 w->resize.step_width = 2; |
1406 w->resize.step_width = 2; |
1394 w->resize.step_height = 10; |
1407 w->resize.step_height = 10; |
1398 WP(w,querystr_d).text.maxlength = lengthof(_edit_str_buf) - 1; |
1411 WP(w,querystr_d).text.maxlength = lengthof(_edit_str_buf) - 1; |
1399 WP(w,querystr_d).text.maxwidth = 240; |
1412 WP(w,querystr_d).text.maxwidth = 240; |
1400 WP(w,querystr_d).text.buf = _edit_str_buf; |
1413 WP(w,querystr_d).text.buf = _edit_str_buf; |
1401 UpdateTextBufferSize(&WP(w, querystr_d).text); |
1414 UpdateTextBufferSize(&WP(w, querystr_d).text); |
1402 |
1415 |
1403 if (mode == SLD_SAVE_GAME) { |
|
1404 GenerateFileName(); |
|
1405 } else if (mode == SLD_SAVE_SCENARIO) |
|
1406 strcpy(_edit_str_buf, "UNNAMED"); |
|
1407 |
|
1408 // pause is only used in single-player, non-editor mode, non-menu mode. It |
1416 // pause is only used in single-player, non-editor mode, non-menu mode. It |
1409 // will be unpaused in the WE_DESTROY event handler. |
1417 // will be unpaused in the WE_DESTROY event handler. |
1410 if(_game_mode != GM_MENU && !_networking && _game_mode != GM_EDITOR) |
1418 if(_game_mode != GM_MENU && !_networking && _game_mode != GM_EDITOR) |
1411 DoCommandP(0, 1, 0, NULL, CMD_PAUSE); |
1419 DoCommandP(0, 1, 0, NULL, CMD_PAUSE); |
1412 |
1420 |