static bool GenerateSpathi_generateMoons (SOLARSYS_STATE *solarSys, PLANET_DESC *planet) { COUNT angle; GenerateDefault_generateMoons (solarSys, planet); if (matchWorld (solarSys, planet, 0, MATCH_PLANET)) { #ifdef NOTYET utf8StringCopy (GLOBAL_SIS (PlanetName), sizeof (GLOBAL_SIS (PlanetName)), "Spathiwa"); #endif /* NOTYET */ solarSys->MoonDesc[0].data_index = PELLUCID_WORLD; solarSys->MoonDesc[0].alternate_colormap = NULL; solarSys->MoonDesc[0].radius = MIN_MOON_RADIUS + MOON_DELTA; angle = NORMALIZE_ANGLE (LOWORD (RandomContext_Random (SysGenRNG))); solarSys->MoonDesc[0].location.x = COSINE (angle, solarSys->MoonDesc[0].radius); solarSys->MoonDesc[0].location.y = SINE (angle, solarSys->MoonDesc[0].radius); ComputeSpeed(&solarSys->MoonDesc[0], TRUE, 1); } return true; }
/* Actually display the menu text */ static void DrawPCMenu (BYTE beg_index, BYTE end_index, BYTE NewState, BYTE hilite, RECT *r) { #define PC_MENU_HEIGHT 8 BYTE pos; COUNT i; int num_items; FONT OldFont; TEXT t; UNICODE buf[256]; pos = beg_index + NewState; num_items = 1 + end_index - beg_index; r->corner.x -= 1; r->extent.width += 1; DrawFilledRectangle (r); if (num_items * PC_MENU_HEIGHT > r->extent.height) log_add (log_Error, "Warning, no room for all menu items!"); else r->corner.y += (r->extent.height - num_items * PC_MENU_HEIGHT) / 2; r->extent.height = num_items * PC_MENU_HEIGHT + 4; DrawPCMenuFrame (r); OldFont = SetContextFont (StarConFont); t.align = ALIGN_LEFT; t.baseline.x = r->corner.x + 2; t.baseline.y = r->corner.y + PC_MENU_HEIGHT -1; t.pStr = buf; t.CharCount = (COUNT)~0; r->corner.x++; r->extent.width -= 2; for (i = beg_index; i <= end_index; i++) { utf8StringCopy (buf, sizeof buf, (i == PM_FUEL) ? pm_fuel_str : (i == PM_CREW) ? pm_crew_str : GAME_STRING (MAINMENU_STRING_BASE + i)); if (hilite && pos == i) { // Currently selected menu option. // Draw the background of the selection. SetContextForeGroundColor (PCMENU_SELECTION_BACKGROUND_COLOR); r->corner.y = t.baseline.y - PC_MENU_HEIGHT + 2; r->extent.height = PC_MENU_HEIGHT - 1; DrawFilledRectangle (r); // Draw the text of the selected item. SetContextForeGroundColor (PCMENU_SELECTION_TEXT_COLOR); font_DrawText (&t); } else { // Draw the text of an unselected item. SetContextForeGroundColor (PCMENU_TEXT_COLOR); font_DrawText (&t); } t.baseline.y += PC_MENU_HEIGHT; } SetContextFont (OldFont); }
// XXX: This code and the entire trackplayer are begging to be overhauled void SpliceTrack (UNICODE *TrackName, UNICODE *TrackText, UNICODE *TimeStamp, CallbackFunction cb) { static UNICODE last_track_name[128] = ""; static unsigned long dec_offset = 0; #define MAX_PAGES 50 UNICODE *pages[MAX_PAGES]; sint32 time_stamps[MAX_PAGES]; int num_pages; int page; if (!TrackText) return; if (!TrackName) { // Appending a piece of subtitles to the last track int slen1, slen2; if (track_count == 0) { log_add (log_Warning, "SpliceTrack(): Tried to append a subtitle," " but no current track"); return; } if (!last_sub || !last_sub->text) { log_add (log_Warning, "SpliceTrack(): Tried to append a subtitle" " to a NULL string"); return; } num_pages = SplitSubPages (TrackText, pages, time_stamps, MAX_PAGES); if (num_pages == 0) { log_add (log_Warning, "SpliceTrack(): Failed to parse subtitles"); return; } // The last page's stamp is a suggested value. The track should // actually play to the end. time_stamps[num_pages - 1] = -time_stamps[num_pages - 1]; // Add the first piece to the last subtitle page slen1 = strlen (last_sub->text); slen2 = strlen (pages[0]); last_sub->text = HRealloc (last_sub->text, slen1 + slen2 + 1); strcpy (last_sub->text + slen1, pages[0]); HFree (pages[0]); // Add the rest of the pages for (page = 1; page < num_pages; ++page) { TFB_SoundChunk *next_sub = find_next_page (last_sub); if (next_sub) { // nodes prepared by previous call, just fill in the subs next_sub->text = pages[page]; last_sub = next_sub; } else { // probably no timestamps were provided, so need more work TFB_SoundDecoder *decoder = SoundDecoder_Load (contentDir, last_track_name, 4096, dec_offset, time_stamps[page]); if (!decoder) { log_add (log_Warning, "SpliceTrack(): couldn't load %s", TrackName); break; } dec_offset += (unsigned long)(decoder->length * 1000); chunks_tail->next = create_SoundChunk (decoder, sound_sample->length); chunks_tail = chunks_tail->next; chunks_tail->tag_me = 1; chunks_tail->track_num = track_count - 1; chunks_tail->text = pages[page]; chunks_tail->callback = cb; // TODO: We may have to tag only one page with a callback //cb = NULL; last_sub = chunks_tail; sound_sample->length += decoder->length; } } } else { // Adding a new track int num_timestamps = 0; utf8StringCopy (last_track_name, sizeof (last_track_name), TrackName); num_pages = SplitSubPages (TrackText, pages, time_stamps, MAX_PAGES); if (num_pages == 0) { log_add (log_Warning, "SpliceTrack(): Failed to parse sutitles"); return; } // The last page's stamp is a suggested value. The track should // actually play to the end. time_stamps[num_pages - 1] = -time_stamps[num_pages - 1]; if (no_page_break && track_count) { int slen1, slen2; slen1 = strlen (last_sub->text); slen2 = strlen (pages[0]); last_sub->text = HRealloc (last_sub->text, slen1 + slen2 + 1); strcpy (last_sub->text + slen1, pages[0]); HFree (pages[0]); } else track_count++; log_add (log_Info, "SpliceTrack(): loading %s", TrackName); if (TimeStamp) { num_timestamps = GetTimeStamps (TimeStamp, time_stamps) + 1; if (num_timestamps < num_pages) { log_add (log_Warning, "SpliceTrack(): number of timestamps" " doesn't match number of pages!"); } else if (num_timestamps > num_pages) { // We most likely will get more subtitles appended later // Set the last page to the rest of the track time_stamps[num_timestamps - 1] = -100000; } } else { num_timestamps = num_pages; } // Reset the offset for the new track dec_offset = 0; for (page = 0; page < num_timestamps; ++page) { TFB_SoundDecoder *decoder = SoundDecoder_Load (contentDir, TrackName, 4096, dec_offset, time_stamps[page]); if (!decoder) { log_add (log_Warning, "SpliceTrack(): couldn't load %s", TrackName); break; } if (!sound_sample) { sound_sample = TFB_CreateSoundSample (NULL, 8, &trackCBs); chunks_head = create_SoundChunk (decoder, 0.0); chunks_tail = chunks_head; } else { chunks_tail->next = create_SoundChunk (decoder, sound_sample->length); chunks_tail = chunks_tail->next; } dec_offset += (unsigned long)(decoder->length * 1000); #if 0 log_add (log_Debug, "page (%d of %d): %d ts: %d", page, num_pages, dec_offset, time_stamps[page]); #endif sound_sample->length += decoder->length; chunks_tail->track_num = track_count - 1; if (!no_page_break) { chunks_tail->tag_me = 1; if (page < num_pages) { chunks_tail->text = pages[page]; last_sub = chunks_tail; } chunks_tail->callback = cb; // TODO: We may have to tag only one page with a callback //cb = NULL; } no_page_break = 0; } } }
static void FeedbackSetting (BYTE which_setting) { UNICODE buf[128]; const char *tmpstr; buf[0] = '\0'; // pre-terminate buffer in case snprintf() overflows buf[sizeof (buf) - 1] = '\0'; switch (which_setting) { case SOUND_ON_SETTING: case SOUND_OFF_SETTING: snprintf (buf, sizeof (buf) - 1, "%s %s", GAME_STRING (OPTION_STRING_BASE + 0), GLOBAL (glob_flags) & SOUND_DISABLED ? GAME_STRING (OPTION_STRING_BASE + 4) : GAME_STRING (OPTION_STRING_BASE + 5)); break; case MUSIC_ON_SETTING: case MUSIC_OFF_SETTING: snprintf (buf, sizeof (buf) - 1, "%s %s", GAME_STRING (OPTION_STRING_BASE + 1), GLOBAL (glob_flags) & MUSIC_DISABLED ? GAME_STRING (OPTION_STRING_BASE + 4) : GAME_STRING (OPTION_STRING_BASE + 5)); break; case VOICE_ON_SETTING: case VOICE_OFF_SETTING: snprintf (buf, sizeof (buf) - 1, "%s %s", GAME_STRING (OPTION_STRING_BASE + 2), GLOBAL (glob_flags) & VOICE_DISABLED ? GAME_STRING (OPTION_STRING_BASE + 4) : GAME_STRING (OPTION_STRING_BASE + 5)); break; case CYBORG_OFF_SETTING: case CYBORG_NORMAL_SETTING: case CYBORG_DOUBLE_SETTING: case CYBORG_SUPER_SETTING: if (optWhichMenu == OPT_PC && which_setting > CYBORG_NORMAL_SETTING) { if (which_setting == CYBORG_DOUBLE_SETTING) tmpstr = "+"; else tmpstr = "++"; } else tmpstr = ""; snprintf (buf, sizeof (buf) - 1, "%s %s%s", GAME_STRING (OPTION_STRING_BASE + 3), !(GLOBAL (glob_flags) & CYBORG_ENABLED) ? GAME_STRING (OPTION_STRING_BASE + 4) : GAME_STRING (OPTION_STRING_BASE + 5), tmpstr); break; case CHANGE_CAPTAIN_SETTING: case CHANGE_SHIP_SETTING: utf8StringCopy (buf, sizeof (buf), GAME_STRING (NAMING_STRING_BASE + 0)); break; } LockMutex (GraphicsLock); DrawStatusMessage (buf); UnlockMutex (GraphicsLock); }