VOID render_do_lbuttonup(HWND hWnd, LONG wParam, LONG lParam) { SKINDATA* skind = &m_current_skin; POINT pt = {LOWORD(lParam), HIWORD(lParam)}; BUTTON *b; int i; for (i = 0; i < skind->m_num_buttons; i++) { b = &skind->m_buttons[i]; if (PtInRect(&b->dest, pt) && b->enabled) { b->mode = BTN_MODE_HOT; b->clicked(); } do_refresh(&b->dest); } }
int LEVELSELECT::Select() { const char noDirectoryName[] = "[kein Verzeichnis]"; BUTTON prevDirButton ({{10, windY - 100}, {90, windY - 50}}, 0, 3, 10, CYAN, "<", 20, YELLOW); BUTTON nextDirButton ({{windX - 100, windY - 100}, {windX - 10, windY - 50}}, 0, 3, 10, CYAN, ">", 20, YELLOW); BUTTON dirCaption ({{100, windY - 100}, {windX - 110, windY - 50}}, 3, 3, 10, CYAN, "(Directory)", 20, YELLOW); BUTTON prevButton ({{10, windY - 180}, {90, windY - 130}}, 0, 3, 10, CYAN, "<", 20, YELLOW); BUTTON nextButton ({{windX - 100, windY - 180}, {windX - 10, windY - 130}}, 0, 3, 10, CYAN, ">", 20, YELLOW); BUTTON selectButton ({{windX - 200, 10}, {windX - 10, 60}}, 0, 3, 10, CYAN, "Spiel starten", 20, YELLOW); BUTTON cancelButton ({{10, 10}, {190, 60}}, 0, 3, 10, CYAN, "Zurück", 20, YELLOW); BUTTON levelCaption ({{100, windY - 180}, {windX - 110, windY - 130}}, 3, 3, 10, CYAN, "(Levelname)", 20, YELLOW); AREA highscoreOutput {{100, 140}, {windX / 2 - 100, windY - 240}}; prevDirButton.assignKeyboardButton(0,'Q'); nextDirButton.assignKeyboardButton(0,'E'); prevButton .assignKeyboardButton(0,GLFW_KEY_LEFT ,'A'); nextButton .assignKeyboardButton(0,GLFW_KEY_RIGHT,'D'); levelCaption .assignKeyboardButton(0,'S'); cancelButton .assignKeyboardButton(0,GLFW_KEY_ESC); selectButton .assignKeyboardButton(0,GLFW_KEY_ENTER,GLFW_KEY_SPACE); ReloadHighscore(); prepare_GameLoop(); do { prepare_graphics(); char levelText[MAX_PATH]; if (GetLevel() != NULL) sprintf(levelText, "%s (%d/%d)", GetLevel()->name, GetLevel()->index + 1, GetLevelCount()); else strcpy(levelText, "[Kein Level vorhanden]"); levelCaption.setText(levelText); const char* directoryName; if (strlen(GetDirectory()->name) > 0) directoryName = GetDirectory()->name; else directoryName = noDirectoryName; char directoryText[strlen(directoryName) + 9]; sprintf(directoryText, "%s (%d/%d)", directoryName, GetDirectory()->index + 1, GetDirectoryCount()); dirCaption.setText(directoryText); //handle clicks if (cancelButton.clicked()) break; else if (selectButton.clicked() && isInputValid()) { currentLevel->score.setTimesPlayed(currentLevel->score.getTimesPlayed() + 1); return true; } else if (prevButton.clicked() || levelCaption.clicked() == 2) SwitchLevel(-1); else if (nextButton.clicked() || levelCaption.clicked() == 1) SwitchLevel(1); else if (prevDirButton.clicked() || dirCaption.clicked() == 2) SwitchDirectory(-1); else if (nextDirButton.clicked() || dirCaption.clicked() == 1) SwitchDirectory(1); //output prevDirButton.print(); nextDirButton.print(); dirCaption.print(); prevButton.print(); nextButton.print(); selectButton.print(); cancelButton.print(); levelCaption.print(); if (currentLevel != NULL) { drawBox({{windX/2 + 80, 140}, {windX - 110, windY - 240}}, 10, 3, WHITE); currentLevel->level->printPreview(); TIME time = currentLevel->score.getTime(); drawBox(highscoreOutput,10,3,WHITE); normalFont.printf({highscoreOutput.a.x + 20, highscoreOutput.b.y - 40}, taLEFT, "Highscore"); normalFont.printf({highscoreOutput.a.x + 20, highscoreOutput.b.y - 80}, taLEFT, "Züge: %d", currentLevel->score.getMoves()); normalFont.printf({highscoreOutput.a.x + 20, highscoreOutput.b.y - 120}, taLEFT, "Zeit: %02d:%02d:%05.2f", time.Hours, time.Minutes, time.Seconds); normalFont.printf({highscoreOutput.a.x + 20, highscoreOutput.b.y - 160}, taLEFT, "%d mal gespielt", currentLevel->score.getTimesPlayed()); } } while (complete_graphics()); logger(true, "LEVELSELECT: Cancelled, Returning false."); return false; }