void WindowSelector::SetAlpha(int nAlpha) { if (projectUtilities::GetTransparent()) { ShowWindow(false); // switch off ToggleTransparency(nAlpha); // switch in ToggleTransparency(nAlpha); ShowWindow(true); } }
virtual void OnClick(Point pt, int widget, int click_count) { if (widget >= WID_TT_BEGIN && widget < WID_TT_END) { if (_ctrl_pressed) { /* toggle the bit of the transparencies lock variable */ ToggleTransparencyLock((TransparencyOption)(widget - WID_TT_BEGIN)); this->SetDirty(); } else { /* toggle the bit of the transparencies variable and play a sound */ ToggleTransparency((TransparencyOption)(widget - WID_TT_BEGIN)); if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); MarkWholeScreenDirty(); } } else if (widget == WID_TT_BUTTONS) { uint i; for (i = WID_TT_BEGIN; i < WID_TT_END; i++) { const NWidgetBase *nwid = this->GetWidget<NWidgetBase>(i); if (IsInsideBS(pt.x, nwid->pos_x, nwid->current_x)) { break; } } if (i == WID_TT_LOADING || i == WID_TT_END) return; ToggleInvisibility((TransparencyOption)(i - WID_TT_BEGIN)); if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); /* Redraw whole screen only if transparency is set */ if (IsTransparencySet((TransparencyOption)(i - WID_TT_BEGIN))) { MarkWholeScreenDirty(); } else { this->SetWidgetDirty(WID_TT_BUTTONS); } } }
void WindowSelector::Init( SelectCallback cbSelect, PlotsCallback minPlotsCallback, TilePlotsCallback tilePlotsCallback) { m_cbSelect = cbSelect; m_minPlotsCallback = minPlotsCallback; m_tilePlotsCallback = tilePlotsCallback; VERIFY(m_bmpPinned.LoadBitmap(IDB_PP_PINNED)); VERIFY(m_bmpUnpinned.LoadBitmap(IDB_PP_UNPINNED)); LPCTSTR lpszClass = AfxRegisterWndClass(CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS, ::LoadCursor(NULL, IDC_ARROW), HBRUSH(COLOR_BTNFACE+1), NULL); int xScreen = ::GetSystemMetrics(SM_CXFULLSCREEN); int yScreen = ::GetSystemMetrics(SM_CYFULLSCREEN); CRect rect(xScreen-120, 0, xScreen, 220); VERIFY(CWnd::CreateEx(WS_EX_PALETTEWINDOW|WS_EX_TOOLWINDOW, lpszClass, "Window List", WS_POPUPWINDOW|WS_CAPTION|WS_THICKFRAME, rect, NULL, 0)); if (!m_wndToolBar.Create(this) //if (!m_wndToolBar.CreateEx(this) || !m_wndToolBar.LoadToolBar(IDR_WINDOW_SELECTOR_TOOLBAR)) { TRACE0("Failed to create toolbar\n"); } m_wndToolBar.SetHeight(10); m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() | CBRS_TOOLTIPS|CBRS_FLYBY|CBRS_SIZE_DYNAMIC ); if (projectUtilities::IsWindows2000()) { w2KDll.Load(); if (!w2KDll.IsLoaded()) { m_wndToolBar.GetToolBarCtrl().HideButton(ID_TOGGLE_TRANSPARENCY, true); } else { if (projectUtilities::GetTransparent()) { ToggleTransparency(projectUtilities::GetAlpha()); } } } else { m_wndToolBar.GetToolBarCtrl().HideButton(ID_TOGGLE_TRANSPARENCY, true); } RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0); VERIFY(m_list.Create(WS_CHILD|WS_VISIBLE|WS_BORDER |LVS_REPORT|LVS_NOCOLUMNHEADER|LVS_SHOWSELALWAYS|LVS_SINGLESEL, rect, this, ID_SELECTION_LIST)); VERIFY(m_list.InsertColumn(0, "", LVCFMT_LEFT, rect.Width()-4) != -1); Redraw(); m_bInit = true; }
virtual EventState OnHotkey(int hotkey) { if (hotkey == GHK_QUIT) { HandleExitGameRequest(); return ES_HANDLED; } /* Disable all key shortcuts, except quit shortcuts when * generating the world, otherwise they create threading * problem during the generating, resulting in random * assertions that are hard to trigger and debug */ if (HasModalProgress()) return ES_NOT_HANDLED; switch (hotkey) { case GHK_ABANDON: /* No point returning from the main menu to itself */ if (_game_mode == GM_MENU) return ES_HANDLED; if (_settings_client.gui.autosave_on_exit) { DoExitSave(); _switch_mode = SM_MENU; } else { AskExitToGameMenu(); } return ES_HANDLED; case GHK_CONSOLE: IConsoleSwitch(); return ES_HANDLED; case GHK_BOUNDING_BOXES: ToggleBoundingBoxes(); return ES_HANDLED; case GHK_DIRTY_BLOCKS: ToggleDirtyBlocks(); return ES_HANDLED; } if (_game_mode == GM_MENU) return ES_NOT_HANDLED; switch (hotkey) { case GHK_CENTER: case GHK_CENTER_ZOOM: { Point pt = GetTileBelowCursor(); if (pt.x != -1) { bool instant = (hotkey == GHK_CENTER_ZOOM && this->viewport->zoom != _settings_client.gui.zoom_min); if (hotkey == GHK_CENTER_ZOOM) MaxZoomInOut(ZOOM_IN, this); ScrollMainWindowTo(pt.x, pt.y, -1, instant); } break; } case GHK_RESET_OBJECT_TO_PLACE: ResetObjectToPlace(); ToolbarSelectLastTool(); break; case GHK_DELETE_WINDOWS: DeleteNonVitalWindows(); break; case GHK_DELETE_NONVITAL_WINDOWS: DeleteAllNonVitalWindows(); break; case GHK_REFRESH_SCREEN: MarkWholeScreenDirty(); break; case GHK_CRASH: // Crash the game *(volatile byte *)0 = 0; break; case GHK_MONEY: // Gimme money /* You can only cheat for money in single player. */ if (!_networking) DoCommandP(0, 10000000, 0, CMD_MONEY_CHEAT); break; case GHK_UPDATE_COORDS: // Update the coordinates of all station signs UpdateAllVirtCoords(); break; case GHK_TOGGLE_TRANSPARENCY: case GHK_TOGGLE_TRANSPARENCY + 1: case GHK_TOGGLE_TRANSPARENCY + 2: case GHK_TOGGLE_TRANSPARENCY + 3: case GHK_TOGGLE_TRANSPARENCY + 4: case GHK_TOGGLE_TRANSPARENCY + 5: case GHK_TOGGLE_TRANSPARENCY + 6: case GHK_TOGGLE_TRANSPARENCY + 7: case GHK_TOGGLE_TRANSPARENCY + 8: /* Transparency toggle hot keys */ ToggleTransparency((TransparencyOption)(hotkey - GHK_TOGGLE_TRANSPARENCY)); MarkWholeScreenDirty(); break; case GHK_TOGGLE_INVISIBILITY: case GHK_TOGGLE_INVISIBILITY + 1: case GHK_TOGGLE_INVISIBILITY + 2: case GHK_TOGGLE_INVISIBILITY + 3: case GHK_TOGGLE_INVISIBILITY + 4: case GHK_TOGGLE_INVISIBILITY + 5: case GHK_TOGGLE_INVISIBILITY + 6: case GHK_TOGGLE_INVISIBILITY + 7: /* Invisibility toggle hot keys */ ToggleInvisibilityWithTransparency((TransparencyOption)(hotkey - GHK_TOGGLE_INVISIBILITY)); MarkWholeScreenDirty(); break; case GHK_TRANSPARENCY_TOOLBAR: ShowTransparencyToolbar(); break; case GHK_TRANSPARANCY: ResetRestoreAllTransparency(); break; #ifdef ENABLE_NETWORK case GHK_CHAT: // smart chat; send to team if any, otherwise to all if (_networking) { const NetworkClientInfo *cio = NetworkClientInfo::GetByClientID(_network_own_client_id); if (cio == NULL) break; ShowNetworkChatQueryWindow(NetworkClientPreferTeamChat(cio) ? DESTTYPE_TEAM : DESTTYPE_BROADCAST, cio->client_playas); } break; case GHK_CHAT_ALL: // send text message to all clients if (_networking) ShowNetworkChatQueryWindow(DESTTYPE_BROADCAST, 0); break; case GHK_CHAT_COMPANY: // send text to all team mates if (_networking) { const NetworkClientInfo *cio = NetworkClientInfo::GetByClientID(_network_own_client_id); if (cio == NULL) break; ShowNetworkChatQueryWindow(DESTTYPE_TEAM, cio->client_playas); } break; case GHK_CHAT_SERVER: // send text to the server if (_networking && !_network_server) { ShowNetworkChatQueryWindow(DESTTYPE_CLIENT, CLIENT_ID_SERVER); } break; #endif default: return ES_NOT_HANDLED; } return ES_HANDLED; }
// ************************************************** void menuFunc(int m) { switch(m) { case MENU_TOGGLE_AMBIENT: ToggleAmbient(); break; case MENU_TOGGLE_DIFFUSE: ToggleDiffuse(); break; case MENU_TOGGLE_SPECULAR: ToggleSpecular(); break; case MENU_TOGGLE_REFLECTIONS: ToggleReflections(); break; case MENU_TOGGLE_TRANSPARENCY: ToggleTransparency(); break; case MENU_TOGGLE_TEXTURING: ToggleTexturing(); break; case MENU_TOGGLE_ANTIALIAS: ToggleAntiAliasing(); break; case MENU_TOGGLE_ATTENUATION: ToggleAttenuation(); break; case MENU_ADD_PRIMITIVE: AddRandomPrimitive(); break; case MENU_ADD_LIGHT: AddRandomLight(); break; case MENU_PRESET_1: LoadPresetScene1(); break; case MENU_PRESET_2: LoadPresetScene2(); break; case MENU_PRESET_3: LoadPresetScene3(); break; case MENU_RESET_SCENE: ResetScene(); break; case MENU_EXPORT_SCENE: ExportScene(); break; default: break; } }
// *********************************************************** // custom keyFunc with preset keys void keyFunc(unsigned char ch, int x, int y) { bool bPostRedisplay = false; switch(ch) { case 'q': case 'Q': bPostRedisplay = false; exit(0); break; case '`': cindex = 0; if(cmode == ControlMode_Lights) printf("Now controlling Light 0.\n"); else printf("Now controlling Primitive 0.\n"); break; case '1': cindex = 1; if(cmode == ControlMode_Lights) printf("Now controlling Light 1.\n"); else printf("Now controlling Primitive 1.\n"); break; case '2': cindex = 2; if(cmode == ControlMode_Lights) printf("Now controlling Light 2.\n"); else printf("Now controlling Primitive 2.\n"); break; case '3': cindex = 3; if(cmode == ControlMode_Lights) printf("Now controlling Light 3.\n"); else printf("Now controlling Primitive 3.\n"); break; case '4': cindex = 4; if(cmode == ControlMode_Lights) printf("Now controlling Light 4.\n"); else printf("Now controlling Primitive 4.\n"); break; case '5': cindex = 5; if(cmode == ControlMode_Lights) printf("Now controlling Light 5.\n"); else printf("Now controlling Primitive 5.\n"); break; case '6': cindex = 6; if(cmode == ControlMode_Lights) printf("Now controlling Light 6.\n"); else printf("Now controlling Primitive 6.\n"); break; case '7': LoadPresetScene1(); break; case '8': LoadPresetScene2(); break; case '9': LoadPresetScene3(); break; case 'A': case 'a': ToggleAmbient(); break; case 'S': case 's': ToggleSpecular(); break; case 'D': case 'd': ToggleDiffuse(); break; case 'R': case 'r': ToggleReflections(); break; case 'T': case 't': ToggleTransparency(); break; case 'E': case 'e': ToggleTexturing(); break; case 'J': case 'j': ToggleAntiAliasing(); break; case 'U': case 'u': ToggleAttenuation(); break; case 'L': case 'l': cmode = ControlMode_Lights; printf("Control Mode: LIGHTS.\n"); break; case 'P': case 'p': cmode = ControlMode_Prims; printf("Control Mode: PRIMITIVES.\n"); break; case 'V': case 'v': TryToggleVisibility(); bPostRedisplay = true; break; case 'M': case 'm': TryCycleMaterial(); bPostRedisplay = true; break; case 'X': case 'x': TryCycleTexture(); bPostRedisplay = true; break; // move controlled object left case '[': TryMove(-2.0f, 0.0f, 0.0f); bPostRedisplay = true; break; // move controlled object right case ']': TryMove(2.0f, 0.0f, 0.0f); bPostRedisplay = true; break; // move controlled object down case '-': TryMove(0.0f, -2.0f, 0.0f); bPostRedisplay = true; break; // move controlled object up case '=': TryMove(0.0f, 2.0f, 0.0f); bPostRedisplay = true; break; case ';': TryMove(0.0f, 0.0f, -2.0f); bPostRedisplay = true; break; case '\'': TryMove(0.0f, 0.0f, 2.0f); bPostRedisplay = true; break; case '.': if( scene->DecreaseRayDepth()) printf("Ray depth decreased to %d.\n", scene->GetRayDepth()); else printf("Ray depth already at 1.\n"); bPostRedisplay = true; break; case ',': if( scene->IncreaseRayDepth()) printf("Ray depth increased to %d.\n", scene->GetRayDepth()); else printf("Ray depth already at max.\n"); bPostRedisplay = true; break; case 'B': case 'b': ExportScene(); break; case 'Z': case 'z': ResetScene(); break; case 'O': case 'o': if(cmode == ControlMode_Lights) { AddRandomLight(); } else { AddRandomPrimitive(); } break; default: /* Unrecognized keypress */ return; } if(bPostRedisplay) glutPostRedisplay(); }
void WindowSelector::OnToggleTransparency() { projectUtilities::SetTransparent(!projectUtilities::GetTransparent()); BYTE nAlpha = projectUtilities::GetAlpha(); ToggleTransparency(nAlpha); }