Exemple #1
0
static void FillSavegameDesc(bool save)
{
	uint8 i;

	for (i = 0; i < 5; i++) {
		char *desc = g_savegameDesc[i];
		char *filename;
		uint8 fileId;

		*desc = '\0';

		if (s_savegameIndexBase - i < 0) continue;

		if (s_savegameIndexBase - i == s_savegameCountOnDisk) {
			if (!save) continue;

			strncpy(desc, String_Get_ByIndex(STR_EMPTY_SLOT_), 50);
			continue;
		}

		filename = GenerateSavegameFilename(s_savegameIndexBase - i);

		if (!File_Exists(filename)) continue;

		fileId = ChunkFile_Open(filename);
		ChunkFile_Read(fileId, HTOBE32(CC_NAME), desc, 50);
		ChunkFile_Close(fileId);
		continue;
	}
}
Exemple #2
0
static void GUI_Mentat_LoadHelpSubjects(bool init)
{
    static uint8 *helpDataList = NULL;

    uint8 fileID;
    uint32 length;
    uint32 counter;
    uint8 *helpSubjects;
    uint16 i;

    if (init) {
        helpDataList = GFX_Screen_Get_ByIndex(SCREEN_1);

        s_topHelpList = 0;
        s_selectedHelpSubject = 0;

        sprintf(s_mentatFilename, "MENTAT%c", g_table_houseInfo[g_playerHouseID].name[0]);
        strncpy(s_mentatFilename, String_GenerateFilename(s_mentatFilename), sizeof(s_mentatFilename));
    }

    fileID = ChunkFile_Open(s_mentatFilename);
    length = ChunkFile_Read(fileID, HTOBE32(CC_NAME), helpDataList, GFX_Screen_GetSize_ByIndex(SCREEN_1));
    ChunkFile_Close(fileID);

    s_numberHelpSubjects = 0;
    helpSubjects = helpDataList;

    counter = 0;
    while (counter < length) {
        uint8 size = *helpSubjects;

        counter += size;

        if (helpSubjects[size - 1] > g_campaignID + 1) {
            while (size-- != 0) *helpSubjects++ = '\0';
            continue;
        }

        helpSubjects[size - 1] = size;
        helpSubjects += size;
        s_numberHelpSubjects++;
    }

    helpSubjects = helpDataList;

    while (*helpSubjects == '\0') helpSubjects++;

    for (i = 0; i < s_topHelpList; i++) helpSubjects = String_NextString(helpSubjects);

    s_helpSubjects = helpSubjects;
}
Exemple #3
0
static void GUI_Mentat_ShowHelp(void)
{
    struct {
        uint8  notused[8];
        uint32 length;
    } info;
    uint8 *subject;
    uint16 i;
    bool noDesc;
    uint8 fileID;
    uint32 offset;
    char *compressedText;
    char *desc;
    char *picture;
    char *text;
    bool loc12;

    subject = s_helpSubjects;

    for (i = 0; i < s_selectedHelpSubject; i++) subject = String_NextString(subject);

    noDesc = (subject[5] == '0');
    offset = HTOBE32(*(uint32 *)(subject + 1));

    fileID = ChunkFile_Open(s_mentatFilename);
    ChunkFile_Read(fileID, HTOBE32(CC_INFO), &info, 12);
    ChunkFile_Close(fileID);

    info.length = HTOBE32(info.length);

    text = g_readBuffer;
    compressedText = GFX_Screen_Get_ByIndex(SCREEN_1);

    fileID = File_Open(s_mentatFilename, FILE_MODE_READ);
    File_Seek(fileID, offset, 0);
    File_Read(fileID, compressedText, info.length);
    String_Decompress(compressedText, text);
    String_TranslateSpecial(text, text);
    File_Close(fileID);

    while (*text != '*' && *text != '?') text++;

    loc12 = (*text == '*');

    *text++ = '\0';

    if (noDesc) {
        uint16 index;

        picture = g_scenario.pictureBriefing;
        desc    = NULL;
        text    = (char *)g_readBuffer;

        index = *text - 44 + g_campaignID * 4 + STR_HOUSE_HARKONNENFROM_THE_DARK_WORLD_OF_GIEDI_PRIME_THE_SAVAGE_HOUSE_HARKONNEN_HAS_SPREAD_ACROSS_THE_UNIVERSE_A_CRUEL_PEOPLE_THE_HARKONNEN_ARE_RUTHLESS_TOWARDS_BOTH_FRIEND_AND_FOE_IN_THEIR_FANATICAL_PURSUIT_OF_POWER + g_playerHouseID * 40;

        strncpy(g_readBuffer, String_Get_ByIndex(index), g_readBufferSize);
    } else {
        picture = (char *)g_readBuffer;
        desc    = text;

        while (*text != '\0' && *text != 0xC) text++;
        if (*text != '\0') *text++ = '\0';
    }

    GUI_Mentat_Loop(picture, desc, text, loc12 ? 1 : 0, g_widgetMentatFirst);

    GUI_Widget_MakeNormal(g_widgetMentatFirst, false);

    GUI_Mentat_LoadHelpSubjects(false);

    GUI_Mentat_Create_HelpScreen_Widgets();

    GUI_Mentat_Draw(true);
}