Exemplo n.º 1
0
void ChooseServerForm::OnControlSelected(word idc) {
    switch (idc) {
    case kidcOk:
        {
            ListControl *plstc = (ListControl *)GetControlPtr(kidcServerList);
            int index = plstc->GetSelectedItemIndex();
            if (index >= 0 && index < infos_.size()) {
                dword result = Connect(infos_[index]);
                if (result == knTransportOpenResultSuccess) {
                    EndForm(kidcOk);
                    break;
                }
                ShowTransportError(result);
            }
        }
        break;

    case kidcRefresh:
        Refresh();
        break;

    case kidcCancel:
        EndForm(kidcCancel);
        break;
    }
}
Exemplo n.º 2
0
void CreateGameForm::OnControlNotify(word idc, int nNotify) {
    if (idc == kidcCategories) {
        RadioButtonBarControl *prbbc =
        (RadioButtonBarControl *)GetControlPtr(kidcCategories);
        int iButtonSelected = prbbc->GetSelectionIndex();
        if (iButtonSelected < 0) {
            iButtonSelected = 0;
        }
        MissionType mtNew = MissionTypeFromIndex(iButtonSelected);
        if (mtNew == m_mt) {
            return;
        }
        SwitchToMissionType(mtNew);
        
        // If in Add-On category, and there is nothing there, show this
        // label, otherwise hide it
        
        bool fShowLabel = false;
        ListControl *plstc =
        m_aplstc[IndexFromMissionType(kmtMultiplayerAddOn)];
        if (m_mt == kmtMultiplayerAddOn) {
            if (plstc->GetCount() == 0) {
                fShowLabel = true;
            }
        }
        
        LabelControl *plbl =
        (LabelControl *)GetControlPtr(kidcAddOnMessage);
        if (fShowLabel) {
            plbl->Show(true);
            if (m_mt == kmtMultiplayerAddOn) {
                plstc->Show(false);
            }
        } else {
            plbl->Show(false);
            if (m_mt == kmtMultiplayerAddOn) {
                plstc->Show(true);
            }
        }
    }
    
    if (idc == kidcChallengeList || idc == kidcAddOnList) {
        UpdateLabels();
    }
    
    // Handle button hiding
    
    bool fShow = true;
    ListControl *plstc = m_aplstc[IndexFromMissionType(m_mt)];
    if (plstc->GetSelectedItemIndex() == -1) {
        fShow = false;
    }
    GetControlPtr(kidcOk)->Show(fShow);
}
Exemplo n.º 3
0
void ChooseServerForm::ShowHide() {
    ListControl *plstc = (ListControl *)GetControlPtr(kidcServerList);
    ButtonControl *pbtn = (ButtonControl *)GetControlPtr(kidcOk);
    int index = plstc->GetSelectedItemIndex();
    if (index < 0 || index >= infos_.size()) {
        pbtn->Show(false);
        return;
    }
    ServerInfo& info = infos_[index];
    if (strcmp(info.status.c_str(), "ok") != 0) {
        pbtn->Show(false);
        return;
    }
    pbtn->Show(true);
}
Exemplo n.º 4
0
void CreateGameForm::UpdateLabels() {
    // Update Game Speed label
    
    char szT[80];
    GetSpeedMultiplierString(szT, m_tGameSpeed);
    LabelControl *plbl = (LabelControl *)GetControlPtr(kidcGameSpeedLabel);
    plbl->SetText(szT);
    
    // Update Mission Pack Info label
    
    plbl = (LabelControl *)GetControlPtr(kidcMissionPackInfo);
    ListControl *plstc = m_aplstc[IndexFromMissionType(m_mt)];
    if (plstc->GetSelectedItemIndex() == -1) {
        plbl->SetText("");
        return;
    }
    int i = (int)plstc->GetSelectedItemData();
    MissionIdentifier miid;
    if (!m_pml->GetMissionIdentifier(i, &miid)) {
        plbl->SetText("");
        return;
    }
    json::JsonMap *map = gppim->GetInfoMap(&miid.packid);
    if (map == NULL) {
        MissionDescription md;
        if (!m_pml->GetMissionDescription(i, &md)) {
            plbl->SetText("");
            return;
        }
        const char *s;
        if (miid.packid.id == PACKID_MAIN) {
            s = base::Format::ToString("%s by Spiffcode, Inc.",
                                       md.szPackName);
        } else {
            s = md.szPackName;
        }
        plbl->SetText((char *)s);
        return;
    }
    const char *szAuthor = GetString(map, "a");
    const char *szTitle = GetString(map, "t");
    const char *s = base::Format::ToString("%s by %s", szTitle, szAuthor);
    plbl->SetText((char *)s);
    delete map;
}
Exemplo n.º 5
0
void DownloadMissionPackForm::HideShow() {
    ListControl *plstc = (ListControl *)GetControlPtr(kidcMissionPackList);
    LabelControl *plbl = (LabelControl *)GetControlPtr(kidcMissionPackInfo);
    ButtonControl *pbtn = (ButtonControl *)GetControlPtr(kidcOk);
    int selected = plstc->GetSelectedItemIndex();
    if (selected < 0) {
        gppim->Reset();
        plbl->SetText("");
        pbtn->Show(false);
        GetControlPtr(kidcDiscuss)->Show(false);
        return;
    }

    // Get the pack info for this pack
       
    IndexEntry *entry = (IndexEntry *)plstc->GetSelectedItemData();
    if (entry == NULL) {
        return;
    }
        
    char *psz = NULL;
    switch (gppackm->IsInstalled(&entry->packid)) {
    case 0:
        psz = "DOWNLOAD";
        break;

    case 1:
        psz = "REMOVE";
        break;

    case 2:
        psz = "UPGRADE";
        break;
    }
    if (psz != NULL) {
        pbtn->SetText(psz);
    }

    pbtn->Show(true);
    ShowInfo(true);
}
Exemplo n.º 6
0
void LobbyForm::OnTimeout(int id) {
    refresh_ = false;
    ListControl *plstc = (ListControl *)GetControlPtr(kidcRoomList);
    dword roomid = (dword)(pword)plstc->GetSelectedItemData();
    if (!selected_main_) {
        roomid = kroomidMain;
    }
    plstc->Clear();
    RoomMap::iterator it = map_.begin();
    for (; it != map_.end(); it++) {
        RoomInfo& info = it->second;
        const char *s;
        if (info.priv) {
            s = base::Format::ToString("\t%s (%d %s, %d %s)\tPRIVATE",
                    info.name.c_str(), info.cPlayers,
                    info.cPlayers == 1 ? "player" : "players",
                    info.cGames,
                    info.cGames == 1 ? "game" : "games");
        } else {
            s = base::Format::ToString("\t%s (%d %s, %d %s)",
                    info.name.c_str(), info.cPlayers,
                    info.cPlayers == 1 ? "player" : "players",
                    info.cGames,
                    info.cGames == 1 ? "game" : "games");
        }
        plstc->Add(s, (void *)(uintptr_t)info.roomid);
    }
    int selected = FindIndex(roomid);
    if (selected < 0 && map_.size() != 0) {
        plstc->Select(0, true, true);
    } else {
        plstc->Select(selected, true);
        selected_main_ = true;
    }
    Control *pctl = GetControlPtr(kidcJoinRoom);
    refresh_ = true;
    pctl->Show(plstc->GetSelectedItemIndex() >= 0);
}