Rev 181 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 181 | Rev 185 | ||
---|---|---|---|
Line 69... | Line 69... | ||
69 | 69 | ||
70 | // completely reset the whole GUI structure so as to NULL out all pointers |
70 | // completely reset the whole GUI structure so as to NULL out all pointers |
71 | memset (&scene->gui, 0, sizeof (scene->gui)); |
71 | memset (&scene->gui, 0, sizeof (scene->gui)); |
72 | 72 | ||
73 | // set the buttons and text locations |
73 | // set the buttons and text locations |
74 | Scene_SetupButton (&scene->gui.llarrow, 0.3f, 0.5f, 2.0f, 4.0f, llarrow_spriteindex, L""); |
74 | Scene_SetupButton (&scene->gui.llarrow, 0.3f, 0.5f, 2.0f, 4.0f, llarrow_spriteindex, NULL, 0.0f, false, false, L""); |
75 | Scene_SetupButton (&scene->gui.larrow, 2.3f, 0.5f, 2.0f, 4.0f, larrow_spriteindex, L""); |
75 | Scene_SetupButton (&scene->gui.larrow, 2.3f, 0.5f, 2.0f, 4.0f, larrow_spriteindex, NULL, 0.0f, false, false, L""); |
76 | Scene_SetupButton (&scene->gui.rarrow, 4.3f, 0.5f, 2.0f, 4.0f, rarrow_spriteindex, L""); |
76 | Scene_SetupButton (&scene->gui.rarrow, 4.3f, 0.5f, 2.0f, 4.0f, rarrow_spriteindex, NULL, 0.0f, false, false, L""); |
77 | Scene_SetupButton (&scene->gui.rrarrow, 6.3f, 0.5f, 2.0f, 4.0f, rrarrow_spriteindex, L""); |
77 | Scene_SetupButton (&scene->gui.rrarrow, 6.3f, 0.5f, 2.0f, 4.0f, rrarrow_spriteindex, NULL, 0.0f, false, false, L""); |
78 | Scene_SetupButton (&scene->gui.newgamebutton, 20.0f, 65.0f, 20.0f, 26.0f, newgamebutton_spriteindex, L" |
78 | Scene_SetupButton (&scene->gui.newgamebutton, 20.0f, 65.0f, 20.0f, 26.0f, newgamebutton_spriteindex, L"Papyrus", 4.0f, false, false, L"\n\n\n\n\n\n\n%s", LOCALIZE (L"NewGame")); |
79 | Scene_SetupButton (&scene->gui.opengamebutton, 60.0f, 65.0f, 20.0f, 26.0f, opengamebutton_spriteindex, L" |
79 | Scene_SetupButton (&scene->gui.opengamebutton, 60.0f, 65.0f, 20.0f, 26.0f, opengamebutton_spriteindex, L"Papyrus", 4.0f, false, false, L"\n\n\n\n\n\n\n%s", LOCALIZE (L"OpenGame")); |
80 | Scene_SetupButton (&scene->gui.chatbutton, 1.0f, 10.0f, 10.0f, 13.0f, chatbutton_spriteindex, L""); |
80 | Scene_SetupButton (&scene->gui.chatbutton, 1.0f, 10.0f, 10.0f, 13.0f, chatbutton_spriteindex, NULL, 0.0f, false, false, L""); |
81 | Scene_SetupButton (&scene->gui.gamesbutton, 1.0f, 35.0f, 10.0f, 13.0f, gamesbutton_spriteindex, L""); |
81 | Scene_SetupButton (&scene->gui.gamesbutton, 1.0f, 35.0f, 10.0f, 13.0f, gamesbutton_spriteindex, NULL, 0.0f, false, false, L""); |
82 | Scene_SetupButton (&scene->gui.peoplebutton, 1.0f, 60.0f, 10.0f, 13.0f, peoplebutton_spriteindex, L""); |
82 | Scene_SetupButton (&scene->gui.peoplebutton, 1.0f, 60.0f, 10.0f, 13.0f, peoplebutton_spriteindex, NULL, 0.0f, false, false, L""); |
83 | 83 | ||
84 | Scene_SetupTextArea (&scene->gui.arrow_text, 4.3f, 5.0f, 0, ALIGN_CENTER, ALIGN_TOP, ALIGN_CENTER, |
84 | Scene_SetupTextArea (&scene->gui.arrow_text, 4.3f, 5.0f, 0, ALIGN_CENTER, ALIGN_TOP, ALIGN_CENTER, L"Papyrus", 3.0f, false, false); // size 24, normal weight, straight typeface |
85 | Scene_SetupTextArea (&scene->gui.comment_text, 50.0f, 0.5f, 80.0f, ALIGN_CENTER, ALIGN_TOP, ALIGN_LEFT, |
85 | Scene_SetupTextArea (&scene->gui.comment_text, 50.0f, 0.5f, 80.0f, ALIGN_CENTER, ALIGN_TOP, ALIGN_LEFT, L"Papyrus", 4.0f, false, false); // size 32, normal weight, straight typeface |
86 | Scene_SetupTextArea (&scene->gui.central_text, 50.0f, 40.0f, 0, ALIGN_CENTER, ALIGN_CENTER, ALIGN_CENTER, |
86 | Scene_SetupTextArea (&scene->gui.central_text, 50.0f, 40.0f, 0, ALIGN_CENTER, ALIGN_CENTER, ALIGN_CENTER, L"Papyrus", 8.0f, false, true); // size 54, normal weight, italic typeface |
87 | Scene_SetupTextArea (&scene->gui.history_text, 100.0f, 50.0f, 0, ALIGN_RIGHT, ALIGN_BOTTOM, ALIGN_LEFT, |
87 | Scene_SetupTextArea (&scene->gui.history_text, 100.0f, 50.0f, 0, ALIGN_RIGHT, ALIGN_BOTTOM, ALIGN_LEFT, L"Papyrus", 4.0f, false, false); // size 32, normal weight, straight typeface |
88 | Scene_SetupTextArea (&scene->gui.clock_text, 99.0f, 66.6f, 0, ALIGN_RIGHT, ALIGN_CENTER, ALIGN_RIGHT, |
88 | Scene_SetupTextArea (&scene->gui.clock_text, 99.0f, 66.6f, 0, ALIGN_RIGHT, ALIGN_CENTER, ALIGN_RIGHT, L"Papyrus", 6.0f, false, true); // size 40, normal weight, italic typeface |
89 | Scene_SetupTextArea (&scene->gui.turn_text, 99.0f, 100.0f, 0, ALIGN_RIGHT, ALIGN_BOTTOM, ALIGN_RIGHT, |
89 | Scene_SetupTextArea (&scene->gui.turn_text, 99.0f, 100.0f, 0, ALIGN_RIGHT, ALIGN_BOTTOM, ALIGN_RIGHT, L"Papyrus", 6.0f, false, true); // size 40, normal weight, italic typeface |
90 | 90 | ||
91 | // remember to update the scene |
91 | // remember to update the scene |
92 | scene->update = true; |
92 | scene->update = true; |
93 | 93 | ||
94 | return; // finished |
94 | return; // finished |
Line 893... | Line 893... | ||
893 | // is it time to play a "start of animation" sound ? (small window of 1/10th sec, if we miss it, don't play anything) |
893 | // is it time to play a "start of animation" sound ? (small window of 1/10th sec, if we miss it, don't play anything) |
894 | if (has_endsound_played && (animation_endtime - ANIMATION_DURATION < current_time) && (animation_endtime - ANIMATION_DURATION + 0.1f > current_time)) |
894 | if (has_endsound_played && (animation_endtime - ANIMATION_DURATION < current_time) && (animation_endtime - ANIMATION_DURATION + 0.1f > current_time)) |
895 | { |
895 | { |
896 | has_endsound_played = false; // an animation just started, remember the ending sound hasn't played yet |
896 | has_endsound_played = false; // an animation just started, remember the ending sound hasn't played yet |
897 | if (is_sliding) |
897 | if (is_sliding) |
898 |
|
898 | Audio_PlaySoundAtSlot (SOUNDTYPE_SLIDE, line, column); // play the sliding move sound |
899 | } |
899 | } |
900 | 900 | ||
901 | // is it time to play an "end of animation" sound ? |
901 | // is it time to play an "end of animation" sound ? |
902 | else if (!has_endsound_played && (animation_endtime - 0.1f < current_time)) |
902 | else if (!has_endsound_played && (animation_endtime - 0.1f < current_time)) |
903 | { |
903 | { |
904 | if (!is_sliding) |
904 | if (!is_sliding) |
905 |
|
905 | Audio_PlaySoundAtSlot (SOUNDTYPE_MOVE, line, column); // play the normal move sound (unless the part was sliding) |
906 | 906 | ||
907 | if (currentmove->has_captured) |
907 | if (currentmove->has_captured) |
908 |
|
908 | Audio_PlaySoundAtSlot (SOUNDTYPE_PIECETAKEN, line, column); // on capture, play the capture sound |
909 | 909 | ||
910 | // is the current player in checkmate, in check, in stalemate or is it a capture ? (to play the right sound) |
910 | // is the current player in checkmate, in check, in stalemate or is it a capture ? (to play the right sound) |
911 | // read as: was the last move an opponent's move AND did it put us to check ? |
911 | // read as: was the last move an opponent's move AND did it put us to check ? |
912 | if (currentmove->is_check) |
912 | if (currentmove->is_check) |
913 | { |
913 | { |
914 | // is it a checkmate or a normal check ? (checkmate == check + stalemate) |
914 | // is it a checkmate or a normal check ? (checkmate == check + stalemate) |
915 | if (currentmove->is_stalemate) |
915 | if (currentmove->is_stalemate) |
916 |
|
916 | Audio_PlaySoundAtCenter (board->players[currentmove->color].type == PLAYER_HUMAN ? SOUNDTYPE_VICTORY : SOUNDTYPE_DEFEAT); // if so, play endgame sound at the center of the board |
917 | else |
917 | else |
918 |
|
918 | Audio_PlaySoundAtCenter (SOUNDTYPE_CHECK); // else play the check sound at the center of the board |
919 | } |
919 | } |
920 | else if (currentmove->is_stalemate) |
920 | else if (currentmove->is_stalemate) |
921 |
|
921 | Audio_PlaySoundAtCenter (SOUNDTYPE_DEFEAT); // on stalemate, play defeat sound at the center of the board |
922 | 922 | ||
923 | has_endsound_played = true; // remember the "end of animation" sound has been played (this will be reset at the beginning of the next animation) |
923 | has_endsound_played = true; // remember the "end of animation" sound has been played (this will be reset at the beginning of the next animation) |
924 | } |
924 | } |
925 | } |
925 | } |
926 | 926 | ||
Line 958... | Line 958... | ||
958 | 958 | ||
959 | if (movement_ratio < 0.9f) |
959 | if (movement_ratio < 0.9f) |
960 | rooksound_played = false; // if the rook is still moving, reset the "sound played" flag |
960 | rooksound_played = false; // if the rook is still moving, reset the "sound played" flag |
961 | else if (!rooksound_played) |
961 | else if (!rooksound_played) |
962 | { |
962 | { |
963 |
|
963 | Audio_PlaySoundAtSlot (SOUNDTYPE_MOVE, line, column); // when the rook has landed, play a move sound |
964 | rooksound_played = true; // remember this is no longer to be done |
964 | rooksound_played = true; // remember this is no longer to be done |
965 | } |
965 | } |
966 | } |
966 | } |
967 | else |
967 | else |
968 | { |
968 | { |
Line 1156... | Line 1156... | ||
1156 | 1156 | ||
1157 | return; // finished, announcement text is set |
1157 | return; // finished, announcement text is set |
1158 | } |
1158 | } |
1159 | 1159 | ||
1160 | 1160 | ||
1161 | void |
1161 | void Scene_AddCCAnnouncement (scene_t *scene, wchar_t *announcement_label, wchar_t *fmt, ...) |
1162 | { |
1162 | { |
1163 | // helper function to set the announcement (red) text on display |
1163 | // helper function to set the announcement (red) text on display |
1164 | 1164 | ||
1165 | static wchar_t message[4096]; |
1165 | static wchar_t message[4096]; |
1166 | ccreply_t re; |
1166 | ccreply_t re; |
Line 1171... | Line 1171... | ||
1171 | _vsnwprintf_s (message, WCHAR_SIZEOF (message), _TRUNCATE, fmt, argptr); |
1171 | _vsnwprintf_s (message, WCHAR_SIZEOF (message), _TRUNCATE, fmt, argptr); |
1172 | va_end (argptr); |
1172 | va_end (argptr); |
1173 | 1173 | ||
1174 | // now put the text in place |
1174 | // now put the text in place |
1175 | memset (&re, 0, sizeof (re)); // reset the structure we're about to fill |
1175 | memset (&re, 0, sizeof (re)); // reset the structure we're about to fill |
- | 1176 | ||
- | 1177 | if (announcement_label != NULL) |
|
- | 1178 | wcscpy_s (re.channelname, WCHAR_SIZEOF (re.channelname), announcement_label); |
|
1176 | 1179 | ||
1177 | re.text_length = wcslen (message); // get text length |
1180 | re.text_length = wcslen (message); // get text length |
1178 | re.text = (wchar_t *) SAFE_malloc (re.text_length + 1, sizeof (wchar_t), false); // allocate text space (include null terminator) |
1181 | re.text = (wchar_t *) SAFE_malloc (re.text_length + 1, sizeof (wchar_t), false); // allocate text space (include null terminator) |
1179 | wcscpy_s (re.text, re.text_length + 1, message); // get the text |
1182 | wcscpy_s (re.text, re.text_length + 1, message); // get the text |
1180 | 1183 | ||
1181 | wcscpy_s (re.channelname, WCHAR_SIZEOF (re.channelname), LOCALIZE (L"ImportantMessage")); |
- | |
1182 | re.color = RGBA_TO_RGBACOLOR (192, 0, 0, 0xE0); // fair red, a bit more opaque than normal messages |
1184 | re.color = RGBA_TO_RGBACOLOR (192, 0, 0, 0xE0); // fair red, a bit more opaque than normal messages |
1183 | re.arrival_time = current_time; // save announcement arrival time |
1185 | re.arrival_time = current_time; // save announcement arrival time |
1184 | 1186 | ||
1185 | // reallocate CC history array to hold now one reply more |
1187 | // reallocate CC history array to hold now one reply more |
1186 | scene->gui.cchistory = (ccreply_t *) SAFE_realloc (scene->gui.cchistory, scene->gui.cchistory_count, scene->gui.cchistory_count + 1, sizeof (ccreply_t), false); |
1188 | scene->gui.cchistory = (ccreply_t *) SAFE_realloc (scene->gui.cchistory, scene->gui.cchistory_count, scene->gui.cchistory_count + 1, sizeof (ccreply_t), false); |
1187 | memcpy (&scene->gui.cchistory[scene->gui.cchistory_count], &re, sizeof (ccreply_t)); |
1189 | memcpy (&scene->gui.cchistory[scene->gui.cchistory_count], &re, sizeof (ccreply_t)); |
1188 | scene->gui.cchistory_count++; // CC history holds now one reply more |
1190 | scene->gui.cchistory_count++; // CC history holds now one reply more |
1189 | 1191 | ||
1190 | return; // finished, announcement text is set |
1192 | return; // finished, announcement text is set |
1191 | } |
1193 | } |
1192 | 1194 | ||
1193 | 1195 | ||
1194 | void Scene_SetupButton (guibutton_t *button, float left_percent, float top_percent, float width_percent, float height_percent, int sprite_index, wchar_t *fmt, ...) |
1196 | void Scene_SetupButton (guibutton_t *button, float left_percent, float top_percent, float width_percent, float height_percent, int sprite_index, wchar_t *font_face, float font_sizepct, bool is_bold, bool is_italic, wchar_t *fmt, ...) |
1195 | { |
1197 | { |
1196 | // helper function to set up a GUI button. WARNING: -1 and NULL in parameter values means "no change"! |
1198 | // helper function to set up a GUI button. WARNING: -1 and NULL in parameter values means "no change"! |
1197 | 1199 | ||
1198 | va_list argptr; |
1200 | va_list argptr; |
1199 | 1201 | ||
1200 | if (left_percent != -1) button->left = left_percent; |
1202 | if (left_percent != -1) button->left = left_percent; |
1201 | if (top_percent != -1) button->top = top_percent; |
1203 | if (top_percent != -1) button->top = top_percent; |
1202 | if (width_percent != -1) button->width = width_percent; |
1204 | if (width_percent != -1) button->width = width_percent; |
1203 | if (height_percent != -1) button->height = height_percent; |
1205 | if (height_percent != -1) button->height = height_percent; |
1204 | if (sprite_index != -1) button->sprite_index = sprite_index; |
1206 | if (sprite_index != -1) button->sprite_index = sprite_index; |
- | 1207 | ||
- | 1208 | if (font_sizepct != -1.0f) button->font_sizepct = font_sizepct; // save the size of the font with which to display this text |
|
- | 1209 | button->font_face = font_face; |
|
- | 1210 | button->is_bold = is_bold; |
|
- | 1211 | button->is_italic = is_italic; // save font face, and whether we want bold or italic text |
|
1205 | 1212 | ||
1206 | // concatenate all the arguments in one string |
1213 | // concatenate all the arguments in one string |
1207 | if (fmt != NULL) |
1214 | if (fmt != NULL) |
1208 | { |
1215 | { |
1209 | va_start (argptr, fmt); |
1216 | va_start (argptr, fmt); |
Line 1215... | Line 1222... | ||
1215 | 1222 | ||
1216 | return; // finished, button is set |
1223 | return; // finished, button is set |
1217 | } |
1224 | } |
1218 | 1225 | ||
1219 | 1226 | ||
1220 | void Scene_SetupTextArea (guitext_t *text, float xpos_percent, float ypos_percent, float maxwidth_percent, int horizontal_align, int vertical_align, int text_align, |
1227 | void Scene_SetupTextArea (guitext_t *text, float xpos_percent, float ypos_percent, float maxwidth_percent, int horizontal_align, int vertical_align, int text_align, wchar_t *font_face, float font_sizepct, bool is_bold, bool is_italic) |
1221 | { |
1228 | { |
1222 | // helper function to set some text on display. WARNING: -1 in parameter values means "no change"! |
1229 | // helper function to set some text on display. WARNING: -1 in parameter values means "no change"! |
1223 | 1230 | ||
1224 | if (xpos_percent != -1) text->xpos_percent = xpos_percent; // save text's X position, in percents from left to right |
1231 | if (xpos_percent != -1) text->xpos_percent = xpos_percent; // save text's X position, in percents from left to right |
1225 | if (ypos_percent != -1) text->ypos_percent = ypos_percent; // save text's Y position, in percents from top to bottom |
1232 | if (ypos_percent != -1) text->ypos_percent = ypos_percent; // save text's Y position, in percents from top to bottom |
1226 | if (maxwidth_percent != -1) text->maxwidth_percent = maxwidth_percent; // save text's max width before word wrapping |
1233 | if (maxwidth_percent != -1) text->maxwidth_percent = maxwidth_percent; // save text's max width before word wrapping |
1227 | if (horizontal_align != -1) text->horizontal_align = horizontal_align; // save text's horizontal alignment regarding the X position |
1234 | if (horizontal_align != -1) text->horizontal_align = horizontal_align; // save text's horizontal alignment regarding the X position |
1228 | if (vertical_align != -1) text->vertical_align = vertical_align; // save text's vertical alignment regarding the Y position |
1235 | if (vertical_align != -1) text->vertical_align = vertical_align; // save text's vertical alignment regarding the Y position |
1229 | if (text_align != -1) text->text_align = text_align; // save text's horizontal alignment inside the bounding rectangle |
1236 | if (text_align != -1) text->text_align = text_align; // save text's horizontal alignment inside the bounding rectangle |
- | 1237 | ||
1230 | if ( |
1238 | if (font_sizepct != -1.0f) text->font_sizepct = font_sizepct; // save the size of the font with which to display this text |
- | 1239 | text->font_face = font_face; |
|
- | 1240 | text->is_bold = is_bold; |
|
- | 1241 | text->is_italic = is_italic; // save font face, and whether we want bold or italic text |
|
1231 | 1242 | ||
1232 | return; // finished, text area is setup |
1243 | return; // finished, text area is setup |
1233 | } |
1244 | } |
1234 | 1245 | ||
1235 | 1246 |