void TacticsVictory::HandleMenuEvent(StringHash, VariantMap& eventData) { int typeEvent = eventData[MenuEvent::P_TYPE].GetInt(); if (typeEvent == MenuEvent_NewGame) { CreateNewGame(); } else if (typeEvent == MenuEvent_OpenEditor) { CreateEditorSession(); } }
void TacticsVictory::Start() { gProfiler = GetSubsystem<Profiler>(); PROFILER_FUNC_ENTER Application::Start(); gTime = GetSubsystem<Time>(); gLog = new Urho3D::Log(gContext); gLog->Open("log.txt"); gLog->SetLevel(Urho3D::LOG_DEBUG); RegistrationFactories(); CreateComponents(); gCache->AddResourceDir(gFileSystem->GetProgramDir() + "../TVData"); gFont = gCache->GetResource<Font>(SET::MENU::FONT::NAME); SetWindowTitleAndIcon(); CreateConsoleAndDebugHud(); XMLFile *style = gCache->GetResource<XMLFile>("UI/MainStyle.xml"); gUIRoot->SetDefaultStyle(style); InitLocalizationSystem(); gCamera = new lCamera(); gGUI->Create(); gFileSelector = new FileSelector(gContext); gFileSelector->GetWindow()->SetModal(false); gFileSelector->GetWindow()->SetVisible(false); SubscribeToEvents(); CreateNewGame(); PROFILER_FUNC_LEAVE }
NewGame::NewGame(QWidget *parent) : QDialog(parent), ui(new Ui::NewGame), _isNetworkGame(false), _createOrJoin(0) { ui->setupUi(this); _game = NULL; _winner = -1; ui->ComputOrHuman->setChecked(true); ui->VsHuman->setChecked(true); ui->WhiteColor->setChecked(true); QObject::connect(ui->ComputOrHuman, SIGNAL(clicked(bool)), this, SLOT(CompVSComp(bool))); QObject::connect(ui->cbNetwork, SIGNAL(clicked(bool)), this, SLOT(NetworkGame(bool))); QObject::connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(CreateNewGame())); QObject::connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(CancelNewGame())); QObject::connect(ui->cbNetwork, SIGNAL(clicked(bool)),this, SLOT(isNetwork(bool))); QObject::connect(ui->btnCreate, SIGNAL(clicked()), this, SLOT(Create())); QObject::connect(ui->btnJoin, SIGNAL(clicked()), this, SLOT(Join())); QObject::connect(ui->listRefresh, SIGNAL(clicked()), this, SLOT(refreshGames())); }
void NewGame::Join() { _createOrJoin = 2; CreateNewGame(); this->hide(); }
void NewGame::Create() { _createOrJoin = 1; CreateNewGame(); this->hide(); }
bool FrameFunc() { if (menu == 1) { int id = UpdateGUI1(); switch(id) { case 1: //menu = 2; //InitiateGUI2(); level_name = "demo.lev"; //if (StartNewGame()) { menu = 0; CreateNewGame(); } break; case 2: { //menu = 2; //InitiateGUI2(); //HANDLE mutex = OpenMutex(MUTEX_ALL_ACCESS, FALSE, NAME_MUTEX1); //if (!mutex) // mutex = CreateMutex(NULL, FALSE, NAME_MUTEX1); //hgeGUIObject *lb = gui->GetCtrl(1); //find_srv = CreateThread(NULL, 0, &FindServer, lb, 0, NULL); } break; case 3: menu = 2; InitiateGUIOptions(); break; case 4: menu = 4; InitiateGUI4(); break; case 5: return true; break; } } else if (menu == 2) { int id = UpdateGUI2(); switch(id) { case 2: /*if (StartNewGame()) { CreateNewGame(); menu = 0; }*/ { hgeGUIListbox *lb = (hgeGUIListbox *)gui->GetCtrl(1); int item = lb->GetSelectedItem(); char *buffer = lb->GetItemText(item); lb = (hgeGUIListbox *)gui->GetCtrl(4); item = lb->GetSelectedItem(); char *temp = lb->GetItemText(item); bool screen_mode = false; if (strcmp("FULL SCREEN", temp) == 0) { screen_mode = false; } else if (strcmp("WINDOWED", temp) == 0) { screen_mode = true; } std::string str(buffer); int index = str.find("x", 0); std::string sub_str1 = str.substr(0, index); std::string sub_str2 = str.substr(index+1); int w = atoi(sub_str1.c_str()); int h = atoi(sub_str2.c_str()); std::ofstream f("options.cfg", std::ios::binary); f.write((const char *)&w, sizeof(int)); f.write((const char *)&h, sizeof(int)); f.write((const char *)&screen_mode, sizeof(bool)); f.close(); menu = 1; InitiateGUI1(); } break; case 3: menu = 1; InitiateGUI1(); break; } } else if (menu == 3) { HANDLE mutex = OpenMutex(MUTEX_ALL_ACCESS, FALSE, NAME_MUTEX1); if (mutex) { WaitForSingleObject(mutex, INFINITE); int id = UpdateGUI3(); switch(id) { case 2: /*TerminateThread(find_srv, 0); if (ConnectToGame()) { menu = 0; }*/ break; case 3: break; case 4: menu = 1; //TerminateThread(find_srv, 0); //find_srv = NULL; InitiateGUI1(); break; } ReleaseMutex(mutex); } } else if (menu == 4) { int id = UpdateGUI4(); switch(id) { case 2: menu = 1; InitiateGUI1(); break; } } else { static float time = 0; hge->Input_GetMousePos(&mouse_pos.x, &mouse_pos.y); float dt = hge->Timer_GetDelta(); time += dt; hard->Update(dt); if (time > 0.025000)//40 fps { if (hge->Input_GetKeyState(HGEK_ESCAPE)) { menu = 1; CloseGame(); InitiateGUI1(); return false; } world->Reset(); if (ENTITY_DEATH != player->GetState()) { HANDLE mutex = OpenMutex(MUTEX_ALL_ACCESS, FALSE, NAME_MUTEX2); if (mutex) { WaitForSingleObject(mutex, INFINITE); if (hge->Input_GetKeyState(HGEK_SPACE) || hge->Input_GetKeyState(HGEK_UP)) { player->Jump(); } if (hge->Input_GetKeyState(HGEK_A) || hge->Input_GetKeyState(HGEK_LEFT)) { player->Move(MOVE_LEFT); } if (hge->Input_GetKeyState(HGEK_D) || hge->Input_GetKeyState(HGEK_RIGHT)) { player->Move(MOVE_RIGHT); } if (hge->Input_GetKeyState(HGEK_K)) { player->Kill(); } player->FaceToTarget(mouse_pos); if (world->GetWorldEntitys()->size() == 0) { if (!next_level_name.empty()) { level_end = 1; } else { level_end = 2; } static float tmp = 0; tmp += hge->Timer_GetDelta(); if (tmp > 0.40) { if (hge->Input_GetKeyState(HGEK_LBUTTON)) { level_end = 0; level_name = next_level_name; if (!level_name.empty()) { CreateNewGame(); } else { menu = 1; CloseGame(); InitiateGUI1(); return false; } tmp = 0; } } } if (hge->Input_GetKeyState(HGEK_LBUTTON)) { player->Attack(mouse_pos); } else { player->RotateWeapon(mouse_pos); } world->GetMap()->ScrollTo(player->GetPos()); ReleaseMutex(mutex); } } else { if (hge->Input_GetKeyState(HGEK_SPACE)) { UpdatePlayerPos(); HANDLE mutex = OpenMutex(MUTEX_ALL_ACCESS, FALSE, NAME_MUTEX2); if (mutex) { WaitForSingleObject(mutex, INFINITE); world->GetMap()->ScrollTo(player->GetPos()); ReleaseMutex(mutex); } } } world->UpdatePositionObjects(); world->UpdateObjects(); time = 0; } if (world->GetWorldEntitys()->size() == 0) { if (!next_level_name.empty()) { level_end = 1; } else { level_end = 2; } } world->UpdateGraphic(); } return false; }
BOOL SessionManagerProc(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam) { BOOL retval = FALSE; int selItem; char tmpName[SESSION_NAME_SIZE]; VuGameEntity* myGame; static int theTimer; switch (message) { case WM_INITDIALOG: SetDlgItemText(hDlg, IDC_SESSION_NAME, F4SessionMemberName); SetDlgItemText(hDlg, IDC_SESSION_GROUP, F4SessionGameName); CheckDlgButton (hDlg, IDC_SESSION_ENABLE, F4SessionManagerOn ? BST_CHECKED : BST_UNCHECKED); F4SessionManagerOn = TRUE; theTimer = SetTimer(hDlg,1,500,NULL); break; case WM_TIMER: F4SessionUpdateGameList(hDlg); F4SessionUpdateMemberList(hDlg); break; case WM_COMMAND: /* message: received a command */ switch (LOWORD(wParam)) { case IDOK: case IDCANCEL: EndDialog(hDlg, TRUE); /* Exits the dialog box */ retval = TRUE; KillTimer (hDlg, theTimer); break; case IDC_SESSION_ENABLE: if (IsDlgButtonChecked(hDlg, IDC_SESSION_ENABLE) == BST_CHECKED) { InitSessionStuff(hDlg); F4SessionUpdateGameList(hDlg); F4SessionUpdateMemberList(hDlg); SetDlgItemText(hDlg, IDC_SESSION_NAME, F4SessionMemberName); SetDlgItemText(hDlg, IDC_SESSION_GROUP, F4SessionGameName); } else EndSessionStuff(); retval = TRUE; break; case IDC_SESSION_CREATE_GROUP: retval = CreateNewGame(hDlg); break; case IDC_SESSION_CHANGE_NAME: NewBoxType = NEW_BOX_NAME; DialogBox(hInst,MAKEINTRESOURCE(IDD_SESSION_NEW),hDlg,(DLGPROC)SessionNewProc); if (dialogReturnString[0]) { vuLocalSessionEntity->SetPlayerCallsign(dialogReturnString); InitSessionStuff(hDlg); } SetDlgItemText(hDlg, IDC_SESSION_NAME, F4SessionMemberName); F4SessionUpdateMemberList(hDlg); retval = TRUE; break; case IDC_SESSION_GROUP_LIST: switch (HIWORD(wParam)) { case LBN_SELCHANGE: case LBN_DBLCLK: selItem = SendDlgItemMessage (hDlg, IDC_SESSION_GROUP_LIST, LB_GETCURSEL, 0, 0); SendDlgItemMessage (hDlg, IDC_SESSION_GROUP_LIST, LB_GETTEXT, selItem, (LPARAM)tmpName); myGame = (VuGameEntity*)vuDatabase->Find ( *((VU_ID*)SendDlgItemMessage (hDlg, IDC_SESSION_GROUP_LIST, LB_GETITEMDATA, selItem, 0))); if ((HIWORD(wParam) == LBN_DBLCLK) && myGame) { gMainThread->LeaveGame(); gMainThread->JoinGame(myGame); InitSessionStuff(hDlg); } F4SessionUpdateMemberList(hDlg); break; } retval = TRUE; break; case IDC_SESSION_EXIT: if (vuLocalSessionEntity->Game() != vuPlayerPoolGroup) gMainThread->LeaveGame(); InitSessionStuff(hDlg); F4SessionUpdateGameList(hDlg); F4SessionUpdateMemberList(hDlg); break; } break; } lParam = wParam; return (retval); }