Exemplo n.º 1
0
void ChooseServerForm::PositionColumns() {
    ListControl *plstc = (ListControl *)GetControlPtr(kidcServerList);
    Rect rcList;
    plstc->GetRect(&rcList);
    Font *pfnt = plstc->GetFont();

    LabelControl *plblPlayers = (LabelControl *)GetControlPtr(kidcNumPlayers);
    int cxNumPlayers = pfnt->GetTextExtent(plblPlayers->GetText());
    int xNumPlayers = rcList.right - cxNumPlayers;
    LabelControl *plblStatus = (LabelControl *)GetControlPtr(kidcServerStatus);
    int cxStatus = pfnt->GetTextExtent(plblStatus->GetText());
    int xStatus = xNumPlayers - 40 - cxStatus;
    int xLocation = rcList.left + (xStatus - rcList.left) / 2;
    int xName = rcList.left;
    
    plstc->SetTabStops(xName - rcList.left, xLocation - rcList.left,
            xStatus + cxStatus / 2 - rcList.left,
            xNumPlayers + cxNumPlayers / 2 - rcList.left);
    plstc->SetTabFlags(0, 0, kfLstTabCenterOn, kfLstTabCenterOn);

    word ids[] = { kidcServerName, kidcServerLocation, kidcServerStatus,
            kidcNumPlayers };
    int ax[] = { xName, xLocation, xStatus, xNumPlayers };

    for (int i = 0; i < ARRAYSIZE(ids); i++) {
        LabelControl *plbl = (LabelControl *)GetControlPtr(ids[i]);
        Rect rcCtl;
        plbl->GetRect(&rcCtl);
        plbl->SetPosition(ax[i], rcCtl.top);
    }
}
Exemplo n.º 2
0
bool LobbyForm::DoModal(int *presult, Sfx sfxShow,  Sfx sfxHide) {
    char name[kcbPlayerName*2];
    handler_.GetPlayerName(name, sizeof(name));
    LabelControl *plbl = (LabelControl *)GetControlPtr(kidcPlayerName);
    plbl->Show(false);
    plbl = (LabelControl *)GetControlPtr(kidcPlayerNameLabel);
    const char *s = base::Format::ToString("%s / %s", name,
        server_name_.c_str());
    plbl->SetText(s);

    ListControl *plstc = (ListControl *)GetControlPtr(kidcRoomList);
    Rect rcList;
    plstc->GetRect(&rcList);
    Font *pfnt = plstc->GetFont();
    int cxPrivate = pfnt->GetTextExtent("PRIVATE");
    int cxStart = rcList.Width() / 20; // 10;
    plstc->SetTabStops(0, cxStart, rcList.Width() - cxStart - cxPrivate);
    plstc->SetTabFlags(0, kfLstTabEllipsis, 0);
    GetControlPtr(kidcJoinRoom)->Show(false);

    Show(true);
    gptra->SetCallback(this);
    dword result = gptra->JoinLobby(this);
    if (result != knLobbyJoinResultSuccess) {
        gptra->SetCallback(NULL);
        ShowJoinMessage(result);
        *presult = 0;
        return false;
    }
    bool success = ShellForm::DoModal(presult, sfxShow, sfxHide);
    gptra->LeaveLobby();
    gptra->SetCallback(NULL);

    return success;
}
Exemplo n.º 3
0
void DownloadMissionPackForm::PositionColumns() {
    // Calc tab stops in the list
    // S  Title # Players Downloads
    // S is + for installed, or ! for upgrade
    // Title is the title. Make this as wide as possible
    // # Players is as close to Downloads as is reasonable
    // # Missions is right aligned

    ListControl *plstc = (ListControl *)GetControlPtr(kidcMissionPackList);
    Font *pfnt = plstc->GetFont();
    LabelControl *plbl = (LabelControl *)GetControlPtr(kidcStatus);
#if 1
    plbl->SetText("");
    int cxPlus = pfnt->GetTextExtent("+");
#else
    int cxPlus = pfnt->GetTextExtent(plbl->GetText());
#endif
    plbl = (LabelControl *)GetControlPtr(kidcTitle);
    int cxTitle = pfnt->GetTextExtent(plbl->GetText());
    plbl = (LabelControl *)GetControlPtr(kidcNumPlayers);
    int cxNumPlayers = pfnt->GetTextExtent(plbl->GetText());
    int cxAsterisk = pfnt->GetTextExtent("*");
    plbl = (LabelControl *)GetControlPtr(kidcNumMissions);
    int cxNumMissions = pfnt->GetTextExtent(plbl->GetText());

    Rect rcList;
    plstc->GetRect(&rcList);

    int xStatus = 2;
    int xTitle = (rcList.Width() / 4 - cxTitle) / 2;
    int xNumMissions = rcList.Width() - cxAsterisk - cxNumMissions;
    int xNumPlayers = xNumMissions - 10 - cxNumPlayers; 
    // Calc the top of the list (past the arrow) for better column
    // label hittesting
    Size sizArrow;
    ListControl::s_ptbmScrollUpUp->GetSize(&sizArrow);
    int yListTop = rcList.top + sizArrow.cy;

    // Set the label positions
    // Enable the labels for hittesting

    Rect rc;
    plbl = (LabelControl *)GetControlPtr(kidcStatus);
    plbl->GetRect(&rc);
    rc.left = rcList.left + xStatus;
    rc.right = xTitle;
    rc.bottom += (yListTop - rc.bottom) / 2;
    plbl->SetRect(&rc);
    plbl->SetFlags(plbl->GetFlags() | kfLblHitTest);
    rcStatus_ = rc;

    plbl = (LabelControl *)GetControlPtr(kidcTitle);
    plbl->GetRect(&rc);
    rc.Offset(rcList.left + xTitle - rc.left, 0);
    rc.right += rc.Width();
    rc.bottom += (yListTop - rc.bottom) / 2;
    plbl->SetRect(&rc);
    plbl->SetFlags(plbl->GetFlags() | kfLblHitTest);
    rcTitle_ = rc;
    
    plbl = (LabelControl *)GetControlPtr(kidcNumPlayers);
    plbl->GetRect(&rc);
    rc.Offset(rcList.left + xNumPlayers - rc.left, 0);
    rc.bottom += (yListTop - rc.bottom) / 2;
    plbl->SetRect(&rc);
    plbl->SetFlags(plbl->GetFlags() | kfLblHitTest);
    rcNumPlayers_ = rc;

    plbl = (LabelControl *)GetControlPtr(kidcNumMissions);
    plbl->GetRect(&rc);
    rc.Offset(rcList.left + xNumMissions - rc.left, 0);
    rc.bottom += (yListTop - rc.bottom) / 2;
    plbl->SetRect(&rc);
    plbl->SetFlags(plbl->GetFlags() | kfLblHitTest);
    rcNumMissions_ = rc;

    // Remember the tab settings for later use

    x0_ = 0;
    x1_ = cxPlus + 4;
    x2_ = xNumPlayers + cxNumPlayers / 2;
    x3_ = xNumMissions + cxNumMissions / 2;
}
Exemplo n.º 4
0
bool CreateGameForm::DoModal(int *pnResult) {
    // Format the lists.
    
    int aidcList[] = { kidcChallengeList, kidcAddOnList };
    for (int i = 0; i < ARRAYSIZE(aidcList); i++) {
        ListControl *plstc = (ListControl *)GetControlPtr(aidcList[i]);
        m_aplstc[i] = plstc;
        Rect rc;
        plstc->GetRect(&rc);
        Font *pfnt = gapfnt[kifntShadow];
        int cxComplete = pfnt->GetTextExtent("Complete");
        int xTitle = rc.Width() / 2 - cxComplete * 3 / 2;
        plstc->SetTabStops(xTitle);
        plstc->SetTabFlags(kfLstTabEllipsis);
        plstc->SetFlags(plstc->GetFlags() | kfLstcKeepInteriorPositioning);
        plstc->Clear();
    }
    
    if (m_pml == NULL) {
        m_pml = CreateMissionList(NULL, kmltMultiplayer);
    }
    if (m_pml == NULL) {
        return false;
    }
    
    // If asked to find a certain mission, find it first to
    // see what type it is, and switch the radio button bar to
    // that type.
    
    int iPack = -1;
    int iMission = -1;
    int cLevels = m_pml->GetCount();
    for (int nLevel = 0; nLevel < cLevels; nLevel++) {
        MissionIdentifier miid;
        m_pml->GetMissionIdentifier(nLevel, &miid);
        if (memcmp(&miid.packid, &m_miidFind.packid,
                   sizeof(miid.packid)) == 0) {
            if (iPack == -1) {
                iPack = nLevel;
            }
            if (strcmp(miid.szLvlFilename,
                       m_miidFind.szLvlFilename) == 0) {
                iMission = nLevel;
                break;
            }
        }
    }
    if (iMission == -1) {
        iMission = iPack;
    }
    int iMissionSelect = iMission;
    
    // Init the lists
    
    MissionType mt = InitLists(iMissionSelect);
    SwitchToMissionType(mt);
    
    // Game Speed
    
    m_tGameSpeed = gtGameSpeed;
    if (m_tGameSpeed < 4)
        m_tGameSpeed = 4;
    SliderControl *psldr = (SliderControl *)GetControlPtr(kidcGameSpeed);
    psldr->SetRange(2, ARRAYSIZE(gatGameSpeeds) - 1 - 3);	// bring the extremes in a bit for multiplayer
    psldr->SetValue(8);
    for (int i = 0; i < ARRAYSIZE(gatGameSpeeds); i++) {
        if (gatGameSpeeds[i] == m_tGameSpeed) {
            psldr->SetValue(i);
            break;
        }
    }
    
    // Hide this label. If we're finding an Add-On mission, then
    // there are add-on missions and this label isn't meant to be visible.
    
    GetControlPtr(kidcAddOnMessage)->Show(false);
    
    UpdateLabels();
    
    gptra->SetCallback(this);
    bool fSuccess = ShellForm::DoModal(pnResult);
    gptra->SetCallback(NULL);
    delete m_pml;
    m_pml = NULL;
    return fSuccess;
}