/* game, and either issuing a 'begin' or 'cancel' command for the created game */
T_void GuildUIConfirmCreateGame (T_void)
{
    DebugRoutine ("GuildUIConfirmCreateGame");

    /* switch control buttons to 'begin game' and 'cancel game' */
    ButtonDelete (G_joinButton);
    ButtonDelete (G_createButton);
    G_joinButton=ButtonCreate (6,
                               127,
                               "UI/GUILD/BEGIN",
                               FALSE,
                               KeyDual(KEY_SCAN_CODE_B,KEY_SCAN_CODE_ALT),
                               NULL,
                               GuildUIBeginGame);

    G_createButton=ButtonCreate (109,
                                 127,
                                 "UI/GUILD/CANCEL",
                                 FALSE,
                                 KeyDual(KEY_SCAN_CODE_C,KEY_SCAN_CODE_ALT),
                                 NULL,
                                 GuildUICancelCreateGame);


    /* delete adventure list box and replace with information */
    /* concerning status */
    TxtboxDelete (G_displayBoxes[GUILD_GAME_LIST]);
    TxtboxDelete (G_displayBoxes[GUILD_MAPS_LIST]);
    ButtonSetCallbacks (G_upButtons[GUILD_GAME_LIST],NULL,NULL);
    ButtonSetCallbacks (G_dnButtons[GUILD_GAME_LIST],NULL,NULL);
    ButtonSetCallbacks (G_upButtons[GUILD_MAPS_LIST],NULL,NULL);
    ButtonSetCallbacks (G_dnButtons[GUILD_MAPS_LIST],NULL,NULL);

    G_displayBoxes[GUILD_GAME_LIST]=TxtboxCreate (6,
                                                  28,
                                                  95,
                                                  75,
                                                  "FontTiny",
                                                  0,
                                                  0,
                                                  FALSE,
                                                  Txtbox_JUSTIFY_CENTER,
                                                  Txtbox_MODE_VIEW_NOSCROLL_FORM,
                                                  NULL);

    TxtboxSetData (G_displayBoxes[GUILD_GAME_LIST],
                   "^003Creating game:^007\r\rplease wait for\rother players\r\r^005Select begin button\rTo start game.");


    DebugEnd();
}
T_void ComwinDisplayCommunicatePage(T_void)
{
   T_TxtboxID TxtboxID;
   T_buttonID buttonID;

   DebugRoutine ("ComwinDisplayCommunicatePage");

   G_comwinIsOpen=TRUE;

   TxtboxID=FormGetObjID(500);
   TxtboxSetData(TxtboxID,G_fielddata);

   /* attach buttons */
   buttonID=FormGetObjID(301);
   ButtonSetCallbacks (buttonID,NULL,ComwinSay);

   DebugEnd();
}
Example #3
0
File: FORM.C Project: LesInk/Test
T_void FormLoadFromFile(T_byte8 *filename)
{
    FILE *fp, *fp2;
    T_word16 i, j;
    T_word16 objtype = 0, objid, x1, y1, x2, y2;
    T_word16 hotkey, toggletype, datatype, fieldtype, fcolor, bcolor, justify;
    T_word16 sbupID, sbdnID, sbgrID;
    T_word16 numericonly;
    T_word32 maxlength;
    T_byte8 picname[32];
    T_byte8 buttontext[256];
    T_byte8 fontname[32];
    T_byte8 tempstr[256];
    T_byte8 tempstr2[256];
    T_byte8 tempstr3[32];
    T_byte8 val;
    E_Boolean isincludedfile = FALSE;
    E_Boolean appendtext = FALSE;
    E_Boolean cursorset = FALSE;
    T_formObjectID objID;
    T_formObjectStruct *p_obj, *p_obj2;
    T_TxtfldStruct *p_txtfld;
    T_buttonStruct *p_button;
    T_buttonID buttonID, SBUbuttonID, SBDbuttonID;
    T_graphicID SBGgraphicID;
    T_sliderID sliderID;
    T_byte8 *p_includedtext;
    T_word32 size;

    DebugRoutine("FormLoadFromFile");
    DebugCheck(filename!=NULL);

    /* first, clean up the form structure and delete any previous forms */
    FormCleanUp();

    /* open up the file */
    fp = fopen(filename, "r");
    DebugCheck(fp!=NULL);
    while (feof(fp) == FALSE) {
        objtype = 0;
        /* get a line from the main file */
        fgets(tempstr, 128, fp);
        /* strip last (newline) character */
        if (tempstr[strlen(tempstr) - 1] == '\n')
            tempstr[strlen(tempstr) - 1] = '\0';

        /* append text to current object if flag is set */
        if (appendtext == TRUE) {
            if (strcmp(tempstr, "ENDOFTEXT") == 0) {
                /* turn off appendstring mode */
                TxtboxBackSpace(p_obj->objID);
                TxtboxCursTop(p_obj->objID);
                TxtboxRepaginate(p_obj->objID);
                TxtboxFirstBox();
                appendtext = FALSE;
                sprintf(tempstr, "#");
            } else if (tempstr[0] != '$' && tempstr[0] != '#') {
                /* strip last character if newline */
                if (tempstr[strlen(tempstr) - 1] == '\n')
                    tempstr[strlen(tempstr) - 1] = '\0';
                TxtboxAppendString(p_obj->objID, tempstr);
                TxtboxAppendKey(p_obj->objID, 13);
                sprintf(tempstr, "#");
            }
        }

        /* check to see if we should open an included file */
        if (tempstr[0] == '$') {
            /* strip the '$' from the string */
            for (i = 1; i < strlen(tempstr); i++)
                tempstr2[i - 1] = tempstr[i];
            tempstr2[i - 1] = '\0';
            /* open an included file */
            p_includedtext = FileLoad(tempstr2, &size);
            TxtboxSetData(p_obj->objID, p_includedtext);
            TxtboxRepaginateAll(p_obj->objID);
            TxtboxCursTop(p_obj->objID);
            MemFree(p_includedtext);

//        	fp2 = fopen (tempstr2,"r");
//	        DebugCheck (fp2!=NULL);
//           isincludedfile=TRUE;

            sprintf(tempstr, "#");
        }

        /* ignore comments and blank lines */
        if (tempstr[0] != '#' && tempstr[0] != ' ') {
            sscanf(tempstr, "%d", &objtype);
            if (objtype == 1) /* add a graphic */
            {
                sscanf(tempstr, "%d,%d,%d,%d,%s", &objtype, &objid, &x1, &y1,
                        picname);
                FormAddGraphic(x1, y1, picname, objid);
            } else if (objtype == 2) /* add a text */
            {
                sscanf(tempstr, "%d,%d,%d,%d,%d,%d", &objtype, &objid, &x1, &y1,
                        &fcolor, &bcolor);
                /* get font name */
                fgets(tempstr, 128, fp);
                sscanf(tempstr, "%s", fontname);
                /* get text */
                fgets(tempstr, 128, fp);
                /* strip last (newline) character */
                if (tempstr[strlen(tempstr) - 1] == '\n')
                    tempstr[strlen(tempstr) - 1] = '\0';
                /* add a text object */
                FormAddText(x1, y1, tempstr, fontname, fcolor, bcolor, objid);
            } else if (objtype == 3) /* add a button */
            {
                sscanf(tempstr, "%d,%d,%d,%d,%d,%d,%s", &objtype, &objid, &x1,
                        &y1, &toggletype, &hotkey, picname);
                FormAddButton(x1, y1, picname, (E_Boolean)toggletype, hotkey,
                        objid);
            } else if (objtype == 4) /* add a text button */
            {
                sscanf(tempstr, "%d,%d,%d,%d,%d,%d", &objtype, &objid, &x1, &y1,
                        &fcolor, &toggletype, &hotkey);
                /* get picture name */
                fgets(tempstr, 128, fp);
                sscanf(tempstr, "%s", picname);
                /* get font name */
                fgets(tempstr, 128, fp);
                sscanf(tempstr, "%s", fontname);
                /* get buttontext */
                fgets(tempstr, 128, fp);
                /* strip last (newline) character */
                if (tempstr[strlen(tempstr) - 1] == '\n')
                    tempstr[strlen(tempstr) - 1] = '\0';
                /* make a text button */
                FormAddTextButton(x1, y1, tempstr, picname, fontname, fcolor, 0,
                        (E_Boolean)toggletype, hotkey, objid);
            } else if (objtype == 5) /* add a text box */
            {
                sscanf(tempstr, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%s",
                        &objtype, &objid, &x1, &y1, &x2, &y2, &maxlength,
                        &numericonly, &justify, &fieldtype, &hotkey, &sbupID,
                        &sbdnID, &sbgrID, fontname);

                /* read in default text */
//                fgets (tempstr,128,fp);
                /* create a text box */
                /* set maximum length to highest possible value if 0 */
                if (maxlength == 0)
                    maxlength--;

                objID = FormAddTextBox(x1, y1, x2, y2, fontname, maxlength,
                        hotkey, numericonly, justify, (E_TxtboxMode)fieldtype,
                        objid);

                DebugCheck(objID != NULL);
                /* set form scroll bar stuff */
                if (sbupID != 0) {
                    SBUbuttonID = FormGetObjID(sbupID);
                    ButtonSetData(SBUbuttonID, objid);
                    ButtonSetCallbacks(SBUbuttonID, NULL, TxtboxHandleSBUp);
                    SBDbuttonID = FormGetObjID(sbdnID);
                    ButtonSetData(SBDbuttonID, objid);
                    ButtonSetCallbacks(SBDbuttonID, NULL, TxtboxHandleSBDn);
                    SBGgraphicID = FormGetObjID(sbgrID);
                    DebugCheck(SBUbuttonID != NULL);
                    DebugCheck(SBDbuttonID != NULL);
                    DebugCheck(SBGgraphicID != NULL);
                    p_obj = (T_formObjectStruct*)objID;
                    TxtboxSetScrollBarObjIDs(p_obj->objID, SBUbuttonID,
                            SBDbuttonID, SBGgraphicID);
                }

                /* set default text */
                p_obj = (T_formObjectStruct *)objID;
                appendtext = TRUE;

            } else if (objtype == 6) /* add a slider */
            {
                sscanf(tempstr, "%d,%d,%d,%d,%d", &objtype, &objid, &x1, &y1,
                        &x2);
                objID = FormAddSlider(x1, y1, x2, objid);
                DebugCheck(objID != NULL);
                p_obj = (T_formObjectStruct *)objID;
                SliderSetCallBack(p_obj->objID, FormReportSlider);
            }
        }
    }
    fclose(fp);
    DebugEnd();
}