예제 #1
0
void Utility::setPalMode() {
  config().video.context->region = 1;
  updateVideoMode();
  resizeMainWindow();
  mainWindow->shrink();
  mainWindow->syncUi();
}
예제 #2
0
void Utility::updateFullscreenState() {
  video.clear();

  if(config.video.isFullscreen == false) {
    config.video.context = &config.video.windowed;
    mainWindow->window->showNormal();
    mainWindow->window->menuBar()->setVisible(true);
    mainWindow->window->statusBar()->setVisible(true);
  } else {
    config.video.context = &config.video.fullscreen;
    mainWindow->window->showFullScreen();
    mainWindow->window->menuBar()->setVisible(!config.system.autoHideMenus);
    mainWindow->window->statusBar()->setVisible(!config.system.autoHideMenus);
  }

  application.processEvents();
  #if defined(PLATFORM_X)
  //Xlib requires time to propogate fullscreen state change message to window manager;
  //if window is resized before this occurs, canvas may not resize correctly
  usleep(50000);
  #endif

  //refresh options that are unique to each video context
  resizeMainWindow();
  updateVideoMode();
  updateHardwareFilter();
  updateSoftwareFilter();
  mainWindow->syncUi();
}
예제 #3
0
void kgeography::openMap()
{
	mapChooser mp(this);
	if (mp.exec() == mapChooser::Accepted)
	{
		showResultsDialog();
		setMap(mp.getMap());
		resizeMainWindow();
	}
}
예제 #4
0
void kgeography::showEvent(QShowEvent *)
{
	if (p_firstShow)
	{
		QString file = kgeographySettings::self() -> lastMap();
		
		if (QFile::exists(file))
		{
			mapReader reader;
			if (reader.parseMap(file))
			{
				setMap(reader.getMap());
			}
			else
			{
				KMessageBox::error(this, i18n("Could not open last used map. Error parsing %1: %2").arg(file).arg(reader.getError()));
				delete reader.getMap();
				openMap();
			}
		}
		else openMap();

		if (!p_map)
		{
			p_currentMap -> setText(i18n("There is no current map"));
			p_consult -> setEnabled(false);
			p_askMap -> setEnabled(false);
			p_askFlagDivisions -> setEnabled(false);
			p_askDivisionFlags -> setEnabled(false);
			p_askCapitalDivisions -> setEnabled(false);
			p_askDivisionCapitals -> setEnabled(false);
		}
		// if anyone can explain why with the slot works and now without
		// i'll be glad to learn
		QTimer::singleShot(0, this, SLOT(resizeMainWindow()));
// 		resizeMainWindow();
		
		p_firstShow = false;
	}
}
예제 #5
0
void Utility::updateFullscreenState() {
  video.clear();

  if(config.video.isFullscreen == false) {
    config.video.context = &config.video.windowed;
    winMain->window->showNormal();
  } else {
    config.video.context = &config.video.fullscreen;
    winMain->window->showFullScreen();
  }

  //Xlib requires time to propogate fullscreen state change message to window manager;
  //if window is resized before this occurs, canvas may not resize correctly
  application.processEvents();
  usleep(50000);

  //refresh options that are unique to each video context
  resizeMainWindow();
  updateVideoMode();
  updateHardwareFilter();
  updateSoftwareFilter();
  winMain->syncUi();
}
예제 #6
0
void Utility::inputEvent(uint16_t code) {
  //forward key-press event
  //(in case window is currently active and capturing a new button / axis assignment)
  winInputCapture->inputEvent(code);

  //if escape key is pressed on *any* keyboard; release the mouse if it is acquired
  for(unsigned i = 0; i < keyboard<>::count; i++) {
    if(code == keyboard<>::index(i, keyboard<>::escape) && inputManager.state(code) && input.acquired()) {
      input.unacquire();
      return;  //do not trigger other UI actions that may be bound to escape key
    }
  }

  if(winMain->window->isActiveWindow()) {
    bool resizeWindow = false;

    if(isButtonDown(code, inputUiGeneral.loadCartridge)) {
      string filename = selectCartridge();
      if(filename.length() > 0) loadCartridge(filename);
    }

    if(isButtonDown(code, inputUiGeneral.pauseEmulation)) {
      application.pause = !application.pause;
    }

    if(isButtonDown(code, inputUiGeneral.resetSystem)) {
      modifySystemState(Reset);
    }

    if(isButtonDown(code, inputUiGeneral.powerCycleSystem)) {
      modifySystemState(PowerCycle);
    }

    if(isButtonDown(code, inputUiGeneral.lowerSpeed)) {
      config.system.speed--;
      updateEmulationSpeed();
      winMain->syncUi();
    }

    if(isButtonDown(code, inputUiGeneral.raiseSpeed)) {
      config.system.speed++;
      updateEmulationSpeed();
      winMain->syncUi();
    }

    if(isButtonDown(code, inputUiGeneral.toggleCheatSystem)) {
      if(cheat.enabled() == false) {
        cheat.enable();
        showMessage("Cheat system enabled.");
      } else {
        cheat.disable();
        showMessage("Cheat system disabled.");
      }
    }

    if(isButtonDown(code, inputUiGeneral.toggleFullscreen)) {
      config.video.isFullscreen = !config.video.isFullscreen;
      updateFullscreenState();
      winMain->syncUi();
    }

    if(isButtonDown(code, inputUiGeneral.toggleMenu)) {
      winMain->window->menuBar()->setVisible(!winMain->window->menuBar()->isVisibleTo(winMain->window));
      resizeWindow = true;
    }

    if(isButtonDown(code, inputUiGeneral.toggleStatus)) {
      winMain->window->statusBar()->setVisible(!winMain->window->statusBar()->isVisibleTo(winMain->window));
      resizeWindow = true;
    }

    //prevent calling twice when toggleMenu == toggleStatus
    if(resizeWindow == true) {
      resizeMainWindow();
    }

    if(isButtonDown(code, inputUiGeneral.exitEmulator)) {
      application.terminate = true;
    }
  }
}
예제 #7
0
void Utility::toggleStatusbar() {
  mainWindow->statusBar->setVisible(!mainWindow->statusBar->isVisibleTo(mainWindow));
  resizeMainWindow();
  mainWindow->shrink();
}
예제 #8
0
void Utility::toggleMenubar() {
  mainWindow->menuBar->setVisible(!mainWindow->menuBar->isVisibleTo(mainWindow));
  resizeMainWindow();
  mainWindow->shrink();
}
예제 #9
0
void Utility::toggleFullscreen() {
  config().video.isFullscreen = !config().video.isFullscreen;
  updateFullscreenState();
  resizeMainWindow();
  mainWindow->syncUi();
}
예제 #10
0
void Utility::setScale(unsigned scale) {
  config().video.context->multiplier = scale;
  resizeMainWindow();
  mainWindow->shrink();
  mainWindow->syncUi();
}
예제 #11
0
void Utility::toggleAspectCorrection() {
  mainWindow->settings_videoMode_correctAspectRatio->toggleChecked();
  config().video.context->correctAspectRatio = mainWindow->settings_videoMode_correctAspectRatio->isChecked();
  resizeMainWindow();
  mainWindow->shrink();
}
예제 #12
0
파일: main.c 프로젝트: david0/neoplace
LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	HINSTANCE hInstance;
	switch (msg) {
	case WM_CREATE:
		{
			hInstance = ((LPCREATESTRUCT) lParam)->hInstance;
			initGUI(hWnd, hInstance);
			resizeMainWindow(hWnd);
			centerOnWindow(hWnd, top_window);
			return 0;
		}

	case WM_COMMAND:
		{
			unsigned x, y;

			for (x = 0; x < BUTTON_COLS; x++)
				for (y = 0; y < BUTTON_ROWS; y++) {
					if (lParam == (LPARAM) buttons[y][x]) {
						if (is_checking) {
							RECT area;

							area.top = min(y, last_click_position.y);
							area.bottom = max(y, last_click_position.y);

							area.left = min(x, last_click_position.x);
							area.right = max(x, last_click_position.x);

							resizeAndMoveWindowTo(top_window, area);
							centerOnWindow(main_window, top_window);
						}
						last_click_position.x = x;
						last_click_position.y = y;
					}
				}

			is_checking = !is_checking;
			return 0;
		}
		break;

		switch (LOWORD(wParam)) {
		case ID_BUTTON_RESIZE:
			if (HIWORD(wParam) == BN_CLICKED) {
				SetWindowPos(top_window, 0, 0, 0, 100, 100, 0);
			}
			return 0;

		}
		break;

	case WM_TIMER:
		{
			HWND foreground = getTopWindow();
			if (foreground != top_window) {
				top_window = foreground;
				if (is_visible) {
					centerOnWindow(hWnd, top_window);
					SetFocus(hWnd);
				}
			}
			SetTimer(hWnd, 1, 500, NULL);
			return 0;
		}

	case WM_KILLFOCUS:
		{
			if (is_visible) {
				SetTimer(hWnd, 1, 200, NULL);
				is_checking = false;
			}
		}
		break;

	case WM_CLOSE:
		{
			toggleWindowVisible();
			return 0;
		}

	}

	return DefWindowProc(hWnd, msg, wParam, lParam);
}
예제 #13
0
void Utility::inputEvent(uint16_t code) {
  //forward key-press event
  //(in case window is currently active and capturing a new button / axis assignment)
  winInputCapture->inputEvent(code);

  for(unsigned i = 0; i < keyboard<>::count; i++) {
    if(code == keyboard<>::index(i, keyboard<>::escape) && inputManager.state(code)) {
      if(mainWindow->window->isActiveWindow() && input.acquired()) {
        //release mouse capture
        input.unacquire();
        return;  //do not trigger other UI actions that may be bound to escape key
      } else if(settingsWindow->window->isActiveWindow()) {
        settingsWindow->window->hide();
        return;
      } else if(toolsWindow->window->isActiveWindow()) {
        toolsWindow->window->hide();
        return;
      }
    }
  }

  if(mainWindow->window->isActiveWindow()) {
    bool resizeWindow = false;

    if(isButtonDown(code, inputUiGeneral.loadCartridge)) {
      string filename = selectCartridge();
      if(filename.length() > 0) loadCartridge(filename);
    }

    if(isButtonDown(code, inputUiGeneral.pauseEmulation)) {
      application.pause = !application.pause;
      if(application.pause) audio.clear();
    }

    if(isButtonDown(code, inputUiGeneral.resetSystem)) {
      modifySystemState(Reset);
    }

    if(isButtonDown(code, inputUiGeneral.powerCycleSystem)) {
      modifySystemState(PowerCycle);
    }

    if(isButtonDown(code, inputUiGeneral.saveScreenshot)) {
      //tell SNES::Interface to save a screenshot at the next video_refresh() event
      interface.saveScreenshot = true;
    }

    if(isButtonDown(code, inputUiGeneral.showStateManager)) {
      toolsWindow->showStateManager();
    }

    if(isButtonDown(code, inputUiGeneral.quickLoad1)) utility.quickLoad(0);
    if(isButtonDown(code, inputUiGeneral.quickLoad2)) utility.quickLoad(1);
    if(isButtonDown(code, inputUiGeneral.quickLoad3)) utility.quickLoad(2);
    if(isButtonDown(code, inputUiGeneral.quickSave1)) utility.quickSave(0);
    if(isButtonDown(code, inputUiGeneral.quickSave2)) utility.quickSave(1);
    if(isButtonDown(code, inputUiGeneral.quickSave3)) utility.quickSave(2);

    if(isButtonDown(code, inputUiGeneral.lowerSpeed)) {
      config.system.speed--;
      updateEmulationSpeed();
      mainWindow->syncUi();
    }

    if(isButtonDown(code, inputUiGeneral.raiseSpeed)) {
      config.system.speed++;
      updateEmulationSpeed();
      mainWindow->syncUi();
    }

    if(isButtonDown(code, inputUiGeneral.toggleCheatSystem)) {
      if(SNES::cheat.enabled() == false) {
        SNES::cheat.enable();
        showMessage("Cheat system enabled.");
      } else {
        SNES::cheat.disable();
        showMessage("Cheat system disabled.");
      }
    }

    if(isButtonDown(code, inputUiGeneral.toggleFullscreen)) {
      config.video.isFullscreen = !config.video.isFullscreen;
      updateFullscreenState();
      mainWindow->syncUi();
    }

    if(isButtonDown(code, inputUiGeneral.toggleMenu)) {
      mainWindow->window->menuBar()->setVisible(!mainWindow->window->menuBar()->isVisibleTo(mainWindow->window));
      resizeWindow = true;
    }

    if(isButtonDown(code, inputUiGeneral.toggleStatus)) {
      mainWindow->window->statusBar()->setVisible(!mainWindow->window->statusBar()->isVisibleTo(mainWindow->window));
      resizeWindow = true;
    }

    //prevent calling twice when toggleMenu == toggleStatus
    if(resizeWindow == true) {
      resizeMainWindow();
    }

    if(isButtonDown(code, inputUiGeneral.exitEmulator)) {
      application.terminate = true;
    }
  }
}