T_void GuildUIStart  (T_word32 formNum)
{
    T_word16 i;

    const T_word16 arrowCoordX[4]=   { 97,  97,  200, 200};
    const T_word16 upArrowCoordY[4]= { 28,  77,  28,  77 };
    const T_word16 dnArrowCoordY[4]= { 67,  117, 67,  117};
    const T_word16 scrollBarY[4]=    { 38,  87,  38,  87 };
    const T_word16 dispWindowX1[4]=  { 6,   6,   109, 109};
    const T_word16 dispWindowY1[4]=  { 28,  77,  28,  77 };
    const T_word16 dispWindowX2[4]=  { 95,  95,  198, 198};
    const T_word16 dispWindowY2[4]=  { 75,  125, 75,  125};

    const E_TxtboxMode dispWindowMode[4]={Txtbox_MODE_SELECTION_BOX,
                                          Txtbox_MODE_VIEW_SCROLL_FORM,
                                          Txtbox_MODE_SELECTION_BOX,
                                          Txtbox_MODE_VIEW_SCROLL_FORM};

    const E_TxtboxJustify dispWindowJustify[4]={Txtbox_JUSTIFY_LEFT,
                                                Txtbox_JUSTIFY_LEFT,
                                                Txtbox_JUSTIFY_CENTER,
                                                Txtbox_JUSTIFY_CENTER};

    DebugRoutine ("GuildUIStart");

    /* load backdrop */
    G_backgroundPic=GraphicCreate (4,3,"UI/GUILD/GLDBACK");

    for (i=GUILD_GAME_LIST;i<=GUILD_MAPS_DESC;i++)
    {
        /* set up display textboxes */
        /* scroll bars and control arrows */
        G_displayBoxes[i]=TxtboxCreate (dispWindowX1[i],
                                        dispWindowY1[i],
                                        dispWindowX2[i],
                                        dispWindowY2[i],
                                        "FontTiny",
                                        0,
                                        0,
                                        FALSE,
                                        dispWindowJustify[i],
                                        dispWindowMode[i],
                                        NULL);
        TxtboxSetData (G_displayBoxes[i]," ");


        G_upButtons[i]=ButtonCreate (arrowCoordX[i],
                                     upArrowCoordY[i],
                                     "UI/COMMON/UPARROW",
                                     FALSE,
                                     0,
                                     NULL,
                                     GuildUIUpDisplay);
        ButtonSetData (G_upButtons[i],i);

        G_dnButtons[i]=ButtonCreate (arrowCoordX[i],
                                     dnArrowCoordY[i],
                                     "UI/COMMON/DNARROW",
                                     FALSE,
                                     0,
                                     NULL,
                                     GuildUIDnDisplay);
        ButtonSetData (G_dnButtons[i],i);

        if (i%2==0)
        {
            G_scrollBars[i]=GraphicCreate (arrowCoordX[i],
                                           scrollBarY[i],
                                           "UI/GUILD/SB1");
        }
        else
        {
            G_scrollBars[i]=GraphicCreate (arrowCoordX[i],
                                           scrollBarY[i],
                                           "UI/GUILD/SB1");
        }

        TxtboxSetScrollBarObjIDs(G_displayBoxes[i],G_upButtons[i],G_dnButtons[i],G_scrollBars[i]);
    }

    /* set up control buttons */
    G_joinButton=ButtonCreate (6,
                               127,
                               "UI/GUILD/JOIN",
                               FALSE,
                               KeyDual(KEY_SCAN_CODE_J,KEY_SCAN_CODE_ALT),
                               NULL,
                               GuildUIJoinGame);

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

    /* build map list */
    GuildUIBuildMapList();

    /* initialize game/player listings */
    G_gameList=DoubleLinkListCreate();
    G_playerList=DoubleLinkListCreate();

    /* set up control callbacks */
    TxtboxSetCallback (G_displayBoxes[GUILD_MAPS_LIST],GuildDisplayMapInfo);
    TxtboxSetCallback (G_displayBoxes[GUILD_GAME_LIST],GuildDisplayGameInfo);

    /* notify server to send a list of active games */
    GuildUIRequestGameList();

    /* update graphics */
    GraphicUpdateAllGraphics();

    /* Set up what we are out. */
    ClientSyncSetGameGroupID(*DirectTalkGetNullBlankUniqueAddress()) ;
    PeopleHereSetOurAdventure(0) ;
    PeopleHereSetOurState(PLAYER_ID_STATE_NONE) ;

    /* Ask for people to show themselves. */
    PeopleHereReset() ;

    /* add journal help page if necessary */
    if (StatsPlayerHasNotePage(30)==FALSE &&
        StatsPlayerHasNotePage(0)==TRUE)
    {
        StatsAddPlayerNotePage(30);
    }

    DebugEnd();
}
Example #2
0
T_void BankUIStart  (T_word32 formNum)
{
    T_word16 i;
    T_byte8 stmp[64];
    E_statsAdventureNumber adv=ADVENTURE_NONE;
    DebugRoutine ("BankUIStart");

    /* load backdrop */
    G_backgroundPic=GraphicCreate (4,3,"UI/BANK/BANKBACK");

    for (i=0;i<4;i++)
    {
        /* load deposit/withdraw buttons */
        G_depositButtons[i]=ButtonCreate(119,
                                         32+(i*11),
                                         "UI/COMMON/LTARROW",
                                         FALSE,
                                         0,
                                         NULL,
                                         BankUIDeposit);

        ButtonSetData(G_depositButtons[i],3-i);

        G_withdrawButtons[i]=ButtonCreate(131,
                                         32+(i*11),
                                         "UI/COMMON/RTARROW",
                                         FALSE,
                                         0,
                                         NULL,
                                         BankUIWithdraw);

        ButtonSetData(G_withdrawButtons[i],3-i);

        /* create financial display fields */
        G_financeDisplays[i]=TxtboxCreate(57,
                                          31+(i*11),
                                          109,
                                          40+(i*11),
                                          "FontMedium",
                                          0,
                                          0,
                                          TRUE,
                                          Txtbox_JUSTIFY_CENTER,
                                          Txtbox_MODE_VIEW_NOSCROLL_FORM,
                                          NULL);

        sprintf (stmp,"%d",StatsGetPlayerSavedCoins(3-i));
        TxtboxSetData(G_financeDisplays[i],stmp);

        G_financeDisplays[i+4]=TxtboxCreate(148,
                                          31+(i*11),
                                          200,
                                          40+(i*11),
                                          "FontMedium",
                                          0,
                                          0,
                                          TRUE,
                                          Txtbox_JUSTIFY_CENTER,
                                          Txtbox_MODE_VIEW_NOSCROLL_FORM,
                                          NULL);

        sprintf (stmp,"%d",StatsGetPlayerCoins(3-i));
        TxtboxSetData(G_financeDisplays[i+4],stmp);

    }

    GraphicUpdateAllGraphics();

    /* set up bank inventory */
    StoreSetUpInventory(10,82,112,124,6,3);

    /* tell store what items we will buy */
    StoreAddBuyType(EQUIP_OBJECT_TYPE_RING);
    StoreAddBuyType(EQUIP_OBJECT_TYPE_AMULET);

    adv=StatsGetCompletedAdventure();

    switch (adv)
    {
        case ADVENTURE_7:
        /* Ring of Strength 2 */
        StoreAddItem (408,1);
        /* Ring of Speed 2 */
        StoreAddItem (430,1);
        /* Amulet of Quickness */
        StoreAddItem (611,1);
		/* Amulet of Hiding */
		StoreAddItem(609, 1);

        case ADVENTURE_6:
        /* Amulet of Speed */
        StoreAddItem (602,1);
        /* Amulet of Mana Regeneration */
        StoreAddItem (619,1);

        case ADVENTURE_5:
        /* Amulet of Accuracy */
        StoreAddItem (605,1);
        /* Ring of Stealth */
		StoreAddItem(438, 1);
		/* Ring of Armor 1 */
        StoreAddItem (415,1);
        /* Amulet of Spell Focus */
        StoreAddItem (600,1);

        case ADVENTURE_4:
		/* Ring of Regen 2 */
		StoreAddItem(406, 1);
		/* Ring of Speed 1 */
        StoreAddItem (429,1);
        /* Ring of Accuracy 2 */
        StoreAddItem (421,1);

        case ADVENTURE_3:
        /* Ring of Strength 1 */
        StoreAddItem (407,1);
        /* Ring of Map */
        StoreAddItem (435,1);

        case ADVENTURE_2:
        /* Ring of Accuracy 1 */
        StoreAddItem (420,1);

        case ADVENTURE_1:
		/* Amulet of Stealth */
		StoreAddItem(603, 1);
		/* Ring of Regen 1 */
		StoreAddItem(405, 1);

        case ADVENTURE_NONE:
        default:
        /* Ring of Food Conservation */
        StoreAddItem (426,1);
        /* Ring of Water Conservation */
        StoreAddItem (427,1);
        /* Ring of Water Walk */
        StoreAddItem (400,1);
        /* Ring of Traction */
        StoreAddItem (432,1);
        break;

        case ADVENTURE_UNKNOWN:
        DebugCheck(0);
        break;
    }


    /* Amulet of Falling */
///  StoreAddItem (614,1);
    /* Ring of Regen 2 */
//    StoreAddItem (406,1);
    /* Ring of Strength 3 */
//    StoreAddItem (409,1);
    /* Ring of Strength 4 */
//    StoreAddItem (410,1);
    /* Ring of Strength 5 */
//    StoreAddItem (411,1);
    /* Ring of Armor 2 */
//    StoreAddItem (416,1);
    /* Ring of Armor 3 */
//    StoreAddItem (417,1);
    /* Ring of Armor 4 */
//    StoreAddItem (418,1);
    /* Ring of Armor 5 */
//    StoreAddItem (419,1);
    /* Ring of Accuracy 3 */
//  StoreAddItem (422,1);
    /* Ring of Accuracy 4 */
//  StoreAddItem (423,1);
    /* Ring of Accuracy 5 */
//  StoreAddItem (424,1);
    /* Ring of Speed 4 */
//  StoreAddItem (428,1);
    /* Ring of Speed 3 */
//  StoreAddItem (431,1);
    /* Ring of Jumping */
//  StoreAddItem (434,1);
    /* Amulet of Regeneration */
//  StoreAddItem (601,1);
    /* Amulet of Strength */
//  StoreAddItem (604,1);
    /* Amulet of Poison Protection */
//  StoreAddItem (606,1);
    /* Amulet of Fire Protection */
//  StoreAddItem (607,1);
    /* Amulet of Lava Walk */
//  StoreAddItem (608,1);
    /* Amulet of Eternal Nourishment */
//  StoreAddItem (610,1);
    /* Amulet of Jumping */
//  StoreAddItem (612,1);
    /* Amulet of Flying */
//  StoreAddItem (613,1);
    /* Amulet of Super Armor */
//  StoreAddItem (615,1);
    /* Amulet of Acid Protection */
//  StoreAddItem (616,1);
    /* Amulet of Electricity Protection */
//  StoreAddItem (617,1);
    /* Amulet of Mana Drain Protection */
//  StoreAddItem (618,1);

    InventoryReorder(INVENTORY_STORE,TRUE);
    InventoryDrawInventoryWindow (INVENTORY_STORE);

    /* set up store control callback */
    StoreSetControlCallback (BankUIUpdateGraphics);

    /* welcome user */
    MessageAdd ("^007Welcome to the bank!");

    /* add journal help page if necessary */
    if (StatsPlayerHasNotePage(33)==FALSE &&
        StatsPlayerHasNotePage(0)==TRUE)
    {
        StatsAddPlayerNotePage(33);
    }
    else
    {
        /* force loading of inventory banner display */
        BannerOpenForm(BANNER_FORM_INVENTORY);
    }

    DebugEnd();
}
T_void InnUIStart(T_word32 formNum)
{
    T_word16 i;
    T_byte8 stmp[32];
    T_word16 hotkey[4];

    DebugRoutine("InnUIStart");

    /* load backdrop */
    G_backgroundPic = GraphicCreate(4, 3, "UI/INN/INNBACK");

    hotkey[0] = KeyDual(KEY_SCAN_CODE_C,KEY_SCAN_CODE_ALT);
    hotkey[1] = KeyDual(KEY_SCAN_CODE_S,KEY_SCAN_CODE_ALT);
    hotkey[2] = KeyDual(KEY_SCAN_CODE_L,KEY_SCAN_CODE_ALT);
    hotkey[3] = KeyDual(KEY_SCAN_CODE_U,KEY_SCAN_CODE_ALT);

    for (i = 0; i < 4; i++) {
        /* place rent buttons */
        sprintf(stmp, "UI/INN/ROOMBTN%d", i + 1);

        G_rentButtons[i] = ButtonCreate(45, 24 + (i * 28), stmp,
        FALSE, hotkey[i],
        NULL, InnUIRent);

        ButtonSetData(G_rentButtons[i], i);

        /* set up rent cost displays */
        G_rentCostDisplays[i] = TxtboxCreate(45, 37 + (i * 28), 110,
                46 + (i * 28), "FontMedium", 0, 0,
                TRUE, Txtbox_JUSTIFY_CENTER, Txtbox_MODE_VIEW_NOSCROLL_FORM,
                NULL);

        /* set up current funds display */
        G_financeDisplays[i] = TxtboxCreate(164, 32 + (i * 11), 204,
                41 + (i * 11), "FontMedium", 0, 0,
                TRUE, Txtbox_JUSTIFY_CENTER, Txtbox_MODE_VIEW_NOSCROLL_FORM,
                NULL);

        sprintf(stmp, "%d", StatsGetPlayerCoins(3-i));
        TxtboxSetData(G_financeDisplays[i], stmp);

    }

    /* set rent prices */
    TxtboxSetData(G_rentCostDisplays[0], "free!");
    TxtboxSetData(G_rentCostDisplays[1], "2 gold");
    TxtboxSetData(G_rentCostDisplays[2], "1 platinum");
    TxtboxSetData(G_rentCostDisplays[3], "2 platinum");

    GraphicUpdateAllGraphics();

    /* welcome user */
    MessageAdd("^007Welcome to the inn!");

    /* add journal help page if necessary */
    if (StatsPlayerHasNotePage(31) == FALSE && StatsPlayerHasNotePage(0) == TRUE) {
        StatsAddPlayerNotePage(31);
    }

    DebugEnd();
}
Example #4
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();
}