@@ -50,6 +50,11 @@ typedef enum DETAIL_HW_TEXT {
50
50
DETAIL_HW_NUMBER_OF = 7 ,
51
51
} DETAIL_HW_TEXT ;
52
52
53
+ typedef struct TEXT_COLUMN_PLACEMENT {
54
+ int option ;
55
+ int col_num ;
56
+ } TEXT_COLUMN_PLACEMENT ;
57
+
53
58
static TEXTSTRING * PassportText = NULL ;
54
59
static TEXTSTRING * DetailTextHW [DETAIL_HW_NUMBER_OF ] = { 0 };
55
60
static TEXTSTRING * DetailText [5 ] = { 0 };
@@ -59,6 +64,32 @@ static TEXTSTRING *CtrlText[2] = { 0 };
59
64
static TEXTSTRING * CtrlTextA [KEY_NUMBER_OF ] = { 0 };
60
65
static TEXTSTRING * CtrlTextB [KEY_NUMBER_OF ] = { 0 };
61
66
67
+ static const TEXT_COLUMN_PLACEMENT CtrlTextPlacementNormal [] = {
68
+ { KEY_UP , 0 }, { KEY_DOWN , 0 }, { KEY_LEFT , 0 }, { KEY_RIGHT , 0 },
69
+ { KEY_STEP_L , 0 }, { KEY_STEP_R , 0 }, { KEY_SLOW , 0 }, { KEY_JUMP , 1 },
70
+ { KEY_ACTION , 1 }, { KEY_DRAW , 1 }, { KEY_LOOK , 1 }, { KEY_ROLL , 1 },
71
+ { -1 , 1 }, { KEY_OPTION , 1 }, { -1 , -1 },
72
+ };
73
+ static const TEXT_COLUMN_PLACEMENT CtrlTextPlacementCheats [] = {
74
+ { KEY_UP , 0 },
75
+ { KEY_DOWN , 0 },
76
+ { KEY_LEFT , 0 },
77
+ { KEY_RIGHT , 0 },
78
+ { KEY_STEP_L , 0 },
79
+ { KEY_STEP_R , 0 },
80
+ { KEY_SLOW , 0 },
81
+ { KEY_JUMP , 0 },
82
+ { KEY_ACTION , 1 },
83
+ { KEY_DRAW , 1 },
84
+ { KEY_LOOK , 1 },
85
+ { KEY_ROLL , 1 },
86
+ { KEY_OPTION , 1 },
87
+ { KEY_FLY_CHEAT , 1 },
88
+ { KEY_ITEM_CHEAT , 1 },
89
+ { KEY_LEVEL_SKIP_CHEAT , 1 },
90
+ { -1 , -1 },
91
+ };
92
+
62
93
static int32_t PassportMode = 0 ;
63
94
static int32_t SelectKey = 0 ;
64
95
@@ -939,7 +970,7 @@ void DoControlOption(INVENTORY_ITEM *inv_item)
939
970
940
971
if (!CtrlText [0 ]) {
941
972
CtrlText [0 ] = T_Print (
942
- 0 , -75 , 0 ,
973
+ 0 , -55 , 0 ,
943
974
GF .strings
944
975
[IConfig ? GS_CONTROL_USER_KEYS : GS_CONTROL_DEFAULT_KEYS ]);
945
976
T_CentreH (CtrlText [0 ], 1 );
@@ -950,6 +981,22 @@ void DoControlOption(INVENTORY_ITEM *inv_item)
950
981
T_AddBackground (CtrlText [0 ], 0 , 0 , 0 , 0 , 48 , IC_BLACK , NULL , 0 );
951
982
}
952
983
984
+ const TEXT_COLUMN_PLACEMENT * cols = T1MConfig .enable_cheats
985
+ ? CtrlTextPlacementCheats
986
+ : CtrlTextPlacementNormal ;
987
+
988
+ const TEXT_COLUMN_PLACEMENT * first_col = NULL ;
989
+ const TEXT_COLUMN_PLACEMENT * last_col = NULL ;
990
+ for (const TEXT_COLUMN_PLACEMENT * col = cols ;
991
+ col -> col_num >= 0 && col -> col_num <= 1 ; col ++ ) {
992
+ if (col -> option != -1 ) {
993
+ if (first_col == NULL ) {
994
+ first_col = col ;
995
+ }
996
+ last_col = col ;
997
+ }
998
+ }
999
+
953
1000
switch (SelectKey ) {
954
1001
case 0 :
955
1002
if (CHK_ANY (InputDB , IN_LEFT | IN_RIGHT )) {
@@ -960,16 +1007,34 @@ void DoControlOption(INVENTORY_ITEM *inv_item)
960
1007
S_WriteUserSettings ();
961
1008
} else {
962
1009
T_RemoveBackground (CtrlTextA [KeyChange ]);
963
- if (KeyChange <= 6 ) {
964
- KeyChange += 7 ;
965
- if (KeyChange == KEY_NUMBER_OF ) {
966
- KeyChange = KEY_NUMBER_OF - 1 ;
1010
+
1011
+ int col_idx [2 ] = { 0 , 0 };
1012
+ const TEXT_COLUMN_PLACEMENT * sel_col ;
1013
+
1014
+ for (sel_col = cols ;
1015
+ sel_col -> col_num >= 0 && sel_col -> col_num <= 1 ;
1016
+ sel_col ++ ) {
1017
+ col_idx [sel_col -> col_num ]++ ;
1018
+ if (sel_col -> option == KeyChange ) {
1019
+ break ;
967
1020
}
968
- } else if (KeyChange == KEY_NUMBER_OF - 1 ) {
969
- KeyChange = 6 ;
970
- } else {
971
- KeyChange -= 7 ;
972
1021
}
1022
+
1023
+ col_idx [!sel_col -> col_num ] = 0 ;
1024
+ for (const TEXT_COLUMN_PLACEMENT * dst_col = cols ;
1025
+ dst_col -> col_num >= 0 && dst_col -> col_num <= 1 ;
1026
+ dst_col ++ ) {
1027
+ if (dst_col -> col_num != sel_col -> col_num ) {
1028
+ col_idx [dst_col -> col_num ]++ ;
1029
+ if (dst_col -> option != -1
1030
+ && col_idx [dst_col -> col_num ]
1031
+ >= col_idx [sel_col -> col_num ]) {
1032
+ KeyChange = dst_col -> option ;
1033
+ break ;
1034
+ }
1035
+ }
1036
+ }
1037
+
973
1038
T_AddBackground (
974
1039
CtrlTextA [KeyChange ], 0 , 0 , 0 , 0 , 48 , IC_BLACK , NULL , 0 );
975
1040
}
@@ -993,7 +1058,7 @@ void DoControlOption(INVENTORY_ITEM *inv_item)
993
1058
994
1059
KeyChange -- ;
995
1060
if (KeyChange < -1 ) {
996
- KeyChange = KEY_NUMBER_OF - 1 ;
1061
+ KeyChange = last_col -> option ;
997
1062
}
998
1063
999
1064
T_AddBackground (
@@ -1004,7 +1069,7 @@ void DoControlOption(INVENTORY_ITEM *inv_item)
1004
1069
KeyChange == -1 ? CtrlText [0 ] : CtrlTextA [KeyChange ]);
1005
1070
1006
1071
KeyChange ++ ;
1007
- if (KeyChange > KEY_NUMBER_OF - 1 ) {
1072
+ if (KeyChange > last_col -> option ) {
1008
1073
KeyChange = -1 ;
1009
1074
}
1010
1075
@@ -1090,104 +1155,72 @@ void DoControlOption(INVENTORY_ITEM *inv_item)
1090
1155
void S_ShowControls ()
1091
1156
{
1092
1157
const int16_t centre = GetRenderWidthDownscaled () / 2 ;
1093
- const int16_t top_y = -50 ;
1158
+ const int16_t top_y = -30 ;
1094
1159
const int16_t row_height = 15 ;
1160
+ int16_t max_y = 0 ;
1095
1161
1096
- CtrlText [1 ] = T_Print (0 , -85 , 0 , " " );
1162
+ CtrlText [1 ] = T_Print (0 , -65 , 0 , " " );
1097
1163
T_CentreH (CtrlText [1 ], 1 );
1098
1164
T_CentreV (CtrlText [1 ], 1 );
1099
1165
1100
- int16_t y ;
1101
- int16_t x1 = 420 ;
1102
- int16_t x2 = centre + 20 ;
1103
- int16_t height = 150 ;
1104
- if (T1MConfig .enable_cheats ) {
1105
- height += row_height * 3 ;
1106
- }
1107
- T_AddBackground (CtrlText [1 ], x1 , height , 0 , 0 , 48 , IC_BLACK , NULL , 0 );
1166
+ const TEXT_COLUMN_PLACEMENT * cols = T1MConfig .enable_cheats
1167
+ ? CtrlTextPlacementCheats
1168
+ : CtrlTextPlacementNormal ;
1108
1169
1109
1170
if (!CtrlTextB [KEY_UP ]) {
1110
1171
int16_t * layout = Layout [IConfig ];
1111
- x1 = centre - 200 ;
1112
- y = top_y ;
1113
-
1114
- for (int i = KEY_UP ; i <= KEY_SLOW ; i ++ ) {
1115
- CtrlTextB [i ] = T_Print (x1 , y , 0 , ScanCodeNames [layout [i ]]);
1116
- y += row_height ;
1117
- }
1118
-
1119
- y = top_y ;
1120
- for (int i = KEY_JUMP ; i <= KEY_ROLL ; i ++ ) {
1121
- CtrlTextB [i ] = T_Print (x2 , y , 0 , ScanCodeNames [layout [i ]]);
1122
- y += row_height ;
1123
- }
1172
+ int16_t xs [2 ] = { centre - 200 , centre + 20 };
1173
+ int16_t ys [2 ] = { top_y , top_y };
1174
+ TRACE ("%d %d x" , ys [0 ], ys [1 ]);
1175
+
1176
+ int text_id = 0 ;
1177
+ for (const TEXT_COLUMN_PLACEMENT * col = cols ;
1178
+ col -> col_num >= 0 && col -> col_num <= 1 ; col ++ ) {
1179
+ int16_t x = xs [col -> col_num ];
1180
+ int16_t y = ys [col -> col_num ];
1181
+ TRACE ("%d %d" , x , y );
1182
+
1183
+ if (col -> option != -1 ) {
1184
+ CtrlTextB [text_id ] =
1185
+ T_Print (x , y , 0 , ScanCodeNames [layout [col -> option ]]);
1186
+ T_CentreV (CtrlTextB [text_id ], 1 );
1187
+ text_id ++ ;
1188
+ }
1124
1189
1125
- if (T1MConfig .enable_cheats ) {
1126
- CtrlTextB [KEY_OPTION ] =
1127
- T_Print (x2 , y , 0 , ScanCodeNames [layout [KEY_OPTION ]]);
1128
- y += row_height ;
1129
- y += row_height ;
1130
- CtrlTextB [KEY_FLY_CHEAT ] =
1131
- T_Print (x2 , y , 0 , ScanCodeNames [layout [KEY_FLY_CHEAT ]]);
1132
- y += row_height ;
1133
- CtrlTextB [KEY_ITEM_CHEAT ] =
1134
- T_Print (x2 , y , 0 , ScanCodeNames [layout [KEY_ITEM_CHEAT ]]);
1135
- y += row_height ;
1136
- CtrlTextB [KEY_LEVEL_SKIP_CHEAT ] =
1137
- T_Print (x2 , y , 0 , ScanCodeNames [layout [KEY_LEVEL_SKIP_CHEAT ]]);
1138
- } else {
1139
- y += row_height ;
1140
- CtrlTextB [KEY_OPTION ] =
1141
- T_Print (x2 , 65 , 0 , ScanCodeNames [layout [KEY_OPTION ]]);
1190
+ ys [col -> col_num ] += row_height ;
1191
+ max_y = MAX (max_y , ys [col -> col_num ]);
1142
1192
}
1143
1193
1144
- for (int i = 0 ; i < KEY_NUMBER_OF ; i ++ ) {
1145
- T_CentreV (CtrlTextB [i ], 1 );
1146
- }
1147
1194
KeyChange = 0 ;
1148
1195
}
1149
1196
1150
1197
if (!CtrlTextA [KEY_UP ]) {
1151
- x1 = centre - 130 ;
1152
- x2 = centre + 90 ;
1153
-
1154
- y = top_y ;
1155
- for (int i = KEY_UP ; i <= KEY_SLOW ; i ++ ) {
1156
- CtrlTextA [i ] =
1157
- T_Print (x1 , y , 0 , GF .strings [i + GS_KEYMAP_RUN - KEY_UP ]);
1158
- y += row_height ;
1159
- }
1160
-
1161
- y = top_y ;
1162
- for (int i = KEY_JUMP ; i <= KEY_ROLL ; i ++ ) {
1163
- CtrlTextA [i ] =
1164
- T_Print (x2 , y , 0 , GF .strings [i + GS_KEYMAP_RUN - KEY_UP ]);
1165
- y += row_height ;
1166
- }
1167
-
1168
- if (T1MConfig .enable_cheats ) {
1169
- CtrlTextA [KEY_OPTION ] =
1170
- T_Print (x2 , y , 0 , GF .strings [GS_KEYMAP_INVENTORY ]);
1171
- y += row_height ;
1172
- y += row_height ;
1173
- CtrlTextA [KEY_FLY_CHEAT ] =
1174
- T_Print (x2 , y , 0 , GF .strings [GS_KEYMAP_FLY_CHEAT ]);
1175
- y += row_height ;
1176
- CtrlTextA [KEY_ITEM_CHEAT ] =
1177
- T_Print (x2 , y , 0 , GF .strings [GS_KEYMAP_ITEM_CHEAT ]);
1178
- y += row_height ;
1179
- CtrlTextA [KEY_LEVEL_SKIP_CHEAT ] =
1180
- T_Print (x2 , y , 0 , GF .strings [GS_KEYMAP_LEVEL_SKIP_CHEAT ]);
1181
- } else {
1182
- y += row_height ;
1183
- CtrlTextA [KEY_OPTION ] =
1184
- T_Print (x2 , y , 0 , GF .strings [GS_KEYMAP_INVENTORY ]);
1185
- }
1198
+ int16_t xs [2 ] = { centre - 130 , centre + 90 };
1199
+ int16_t ys [2 ] = { top_y , top_y };
1200
+ TRACE ("%d %d" , ys [0 ], ys [1 ]);
1201
+
1202
+ int text_id = 0 ;
1203
+ for (const TEXT_COLUMN_PLACEMENT * col = cols ;
1204
+ col -> col_num >= 0 && col -> col_num <= 1 ; col ++ ) {
1205
+ int16_t x = xs [col -> col_num ];
1206
+ int16_t y = ys [col -> col_num ];
1207
+ TRACE ("%d %d" , x , y );
1208
+
1209
+ if (col -> option != -1 ) {
1210
+ CtrlTextA [text_id ] = T_Print (
1211
+ x , y , 0 , GF .strings [col -> option + GS_KEYMAP_RUN - KEY_UP ]);
1212
+ T_CentreV (CtrlTextA [text_id ], 1 );
1213
+ text_id ++ ;
1214
+ }
1186
1215
1187
- for ( int i = 0 ; i < KEY_NUMBER_OF ; i ++ ) {
1188
- T_CentreV ( CtrlTextA [ i ], 1 );
1216
+ ys [ col -> col_num ] += row_height ;
1217
+ max_y = MAX ( max_y , ys [ col -> col_num ] );
1189
1218
}
1190
1219
}
1220
+
1221
+ int16_t width = 420 ;
1222
+ int16_t height = 3 * row_height + max_y - top_y ;
1223
+ T_AddBackground (CtrlText [1 ], width , height , 0 , 0 , 48 , IC_BLACK , NULL , 0 );
1191
1224
}
1192
1225
1193
1226
void S_ChangeCtrlText ()
0 commit comments