void SettingsWindow::SaveValues() { auto appSettings(GetAppSettings().lock()); assert(appSettings); GetDieFace(); appSettings->DeathThreshold ( GetValue ( f_table, DeathThreshold ) ); appSettings->CombatantListFont ( GetFontName( f_table, CharListFont ) ); appSettings->AltCombatantListFont( GetFontName( f_table, AltCharListFont ) ); Gtk::TreeModel::iterator iter = f_model->children().begin(); const Gtk::TreeModel::iterator end = f_model->children().end(); // for( ; iter != end; ++iter ) { Gtk::TreeModel::Row row = *iter; const mo_name_t id = row[f_columns.f_id]; const bool active = row[f_columns.f_active]; if( id == (mo_name_t) moName(UltraInit) ) { appSettings->UltraInit( active ); } if( id == (mo_name_t) moName(BleedOut) ) { appSettings->BleedOutDying( active ); } if( id == (mo_name_t) moName(SkipDead) ) { appSettings->SkipDead( active ); } if( id == (mo_name_t) moName(AltDeathRule)) { appSettings->AlternateDeathRule( active ); } if( id == (mo_name_t) moName(NotifyExpiredEffects)) { appSettings->NotifyExpiredEffects( active );} if( id == (mo_name_t) moName(InitOnStart) ) { appSettings->InitOnStart( active ); } if( id == (mo_name_t) moName(ManualInit) ) { appSettings->ManualInit( active ); } if( id == (mo_name_t) moName(GetDC) ) { appSettings->GetDC( active ); } } appSettings->signal_changed().emit(); }
SortTransaction::SortTransaction( const molib::mo_name_t id, const int dc ) : f_sortId(id) , f_dc(dc) { f_prevDC = GetAppSettings().lock()->LastDC(); f_prevSortId = GetCharacterModel().lock()->getSoftSort(); }
void SettingsWindow::GetDieFace() { int dice, faces, modifier; Gtk::ComboBoxEntryText* cb = 0; f_table.GetItem( InitDie, cb ); assert(cb); const Glib::ustring dice_info( cb->get_entry()->get_text() ); Common::StrToDiceFacesModifier( dice_info.c_str(), dice, faces, modifier ); f_initStat->dice ( dice ); f_initStat->faces ( faces ); f_initStat->modifier ( modifier ); GetStatMgr().lock()->signal_changed().emit(); auto appSettings(GetAppSettings().lock()); assert(appSettings); // auto die_list( appSettings->InitDieStrings() ); const auto match_iter = std::find_if( die_list.begin(), die_list.end(), [&]( const Glib::ustring& s ) -> bool { return s == dice_info; }); // if( match_iter != die_list.end() ) { // Save strings with new entry // die_list.push_back( dice_info ); appSettings->InitDieStrings( die_list ); } }
/** \brief * * Called when the window is hidden. * * \todo Add functionality as needed to handle CharacterListUI object hiding. */ void HUDWindow::on_hide() { auto appSettings(GetAppSettings().lock()); assert(appSettings); // Store window position // int x, y; Glib::RefPtr<Gdk::Window> window = get_window(); window->get_root_origin( x, y ); // appSettings->HUDX( x ); appSettings->HUDY( y ); // Store window dimensions // int width, height; get_size( width, height ); // appSettings->HUDWidth( width ); appSettings->HUDHeight( height ); // Stop listening to this change now that we are hidden // f_connectChangeFont.disconnect(); // Do the rest // Gtk::Window::on_hide(); }
void SettingsWindow::InitTreeView() { auto appSettings(GetAppSettings().lock()); assert(appSettings); f_model = Gtk::ListStore::create( f_columns ); f_treeView.set_model( f_model ); f_treeView.append_column( gettext("Name"), f_columns.f_name ); f_treeView.append_column_editable( gettext("Active"), f_columns.f_active ); Gtk::TreeModel::Row row; // row = *(f_model->append()); row[f_columns.f_id] = moName(UltraInit); row[f_columns.f_name] = gettext("Use Ulta Initiative (roll initiative each round)"); row[f_columns.f_active] = appSettings->UltraInit(); // row = *(f_model->append()); row[f_columns.f_id] = moName(BleedOut); row[f_columns.f_name] = gettext("Bleed Out Dying Combatants"); row[f_columns.f_active] = appSettings->BleedOutDying(); // row = *(f_model->append()); row[f_columns.f_id] = moName(SkipDead); row[f_columns.f_name] = gettext("Skip Dead Combatants"); row[f_columns.f_active] = appSettings->SkipDead(); // row = *(f_model->append()); row[f_columns.f_id] = moName(AltDeathRule); row[f_columns.f_name] = gettext("Use Alternate Death Rule (death at threshold minus character level)"); row[f_columns.f_active] = appSettings->AlternateDeathRule(); // row = *(f_model->append()); row[f_columns.f_id] = moName(NotifyExpiredEffects); row[f_columns.f_name] = gettext("Notify when effects expire on combatant's turn"); row[f_columns.f_active] = appSettings->NotifyExpiredEffects(); // row = *(f_model->append()); row[f_columns.f_id] = moName(InitOnStart); row[f_columns.f_name] = gettext("Roll Initiative on Start"); row[f_columns.f_active] = appSettings->InitOnStart(); // row = *(f_model->append()); row[f_columns.f_id] = moName(ManualInit); row[f_columns.f_name] = gettext("Manual Initiative Entry"); row[f_columns.f_active] = appSettings->ManualInit(); // row = *(f_model->append()); row[f_columns.f_id] = moName(GetDC); row[f_columns.f_name] = gettext("Get DC on Rolls"); row[f_columns.f_active] = appSettings->GetDC(); }
// --------------------------------------------------------------------- //! カバーブラウザの表示/非表示を切り替えます。 // --------------------------------------------------------------------- void WinCoveredCalcApp::ShowCoverBrowser( bool isShow //!< true なら表示、false なら非表示 ) { if (!::IsWindow(coverBrowser.m_hWnd)) { return; } ::ShowWindow(coverBrowser.m_hWnd, (isShow) ? SW_SHOW : SW_HIDE); GetAppSettings()->SetCoverBrowserVisible(IsCoverBrowserVisible()); // TODO: このタイミングで保存はしたくないが、最後に保存されないのは困る。modify flag が欲しいな…。 }
void HUDWindow::OnHUDChangeFont() { auto appSettings(GetAppSettings().lock()); assert(appSettings); Gtk::FontSelectionDialog dlg( "Select Player HUD Font" ); dlg.set_font_name( appSettings->AltCombatantListFont().c_str() ); if( dlg.run() == Gtk::RESPONSE_OK ) { appSettings->AltCombatantListFont( dlg.get_font_name().c_str() ); appSettings->signal_changed().emit(); } }
/** * @brief キーマップ定義を読み込みます。initInstance の処理で呼ばれます。 */ void WinCoveredCalcApp::loadKeyMappingsOnInit() { Path keymapFile; AppSettings* appSettings = GetAppSettings(); keymapFile = appSettings->GetKeymapFilePath(); if (keymapFile.IsEmpty()) { // 設定になければデフォルト // FIXME: ユーザに尋ねる? // トリック: // 1.8.x まではカスタマイズがなくて日本語 JIS キーボードしかなかった。 // デフォルト設定としては US QWERTY(標準的な 101/104 拡張キーボード)がよいが、 // 言語が日本語の場合は以前のまま日本語 JIS キーボードの方が好ましい。 // それ以外の場合に US QWERTY キーボードにする。 MBCString langCode; GetCurrentLanguageCode(langCode); if (0 == langCode.Compare(LANG_CODE_JAJP)) { keymapFile.AssignFromSlashSeparated(ALITERAL("${") VPATH_APP_KEYMAPS ALITERAL("}/JapaneseJIS.cckxw")); } else { keymapFile.AssignFromSlashSeparated(ALITERAL("${") VPATH_APP_KEYMAPS ALITERAL("}/UsQWERTY.cckxw")); } appSettings->SetKeymapFilePath(keymapFile); } Path absolutePath = ExpandVirtualPath(keymapFile); try { LoadKeyMappings(absolutePath); } catch (Exception* ex) { // キーマッピング定義が読み込めませんでした。 ExceptionMessageUtils::DoExceptionMessageBoxWithText(this, ex, NSID_EMSG_LOAD_KEYMAPPINGS, MessageBoxProvider::ButtonType_OK, MessageBoxProvider::AlertType_Warning); ex->Delete(); } }
void SettingsWindow::UpdateDialog() { auto appSettings(GetAppSettings().lock()); assert(appSettings); Gtk::ComboBoxEntryText* cb = 0; f_table.GetItem( InitDie, cb ); assert(cb); cb->clear_items(); for( auto str : appSettings->InitDieStrings() ) { cb->append_text( str ); } SetDieFace(); SetValue( f_table, DeathThreshold, appSettings->DeathThreshold() ); SetFontName( f_table, CharListFont , appSettings->CombatantListFont() ); SetFontName( f_table, AltCharListFont, appSettings->AltCombatantListFont() ); }
/** \brief * * Position window to stored size */ void HUDWindow::PositionWindow() { auto appSettings(GetAppSettings().lock()); assert(appSettings); const int x = appSettings->HUDX(); const int y = appSettings->HUDY(); const int w = appSettings->HUDWidth(); const int h = appSettings->HUDHeight(); Glib::RefPtr<Gdk::Screen> screen = Gdk::Screen::get_default(); // const int screen_height = screen->get_height(); const int screen_width = screen->get_width(); bool use_defaults = (x == -1); if( (x > screen_width) || (y > screen_height) || (x+w > screen_width) || (y+h > screen_height) ) { use_defaults = true; } if( use_defaults ) { set_position( Gtk::WIN_POS_CENTER ); set_default_size( 640, 480 ); } else { set_default_size( appSettings->HUDWidth(), appSettings->HUDHeight() ); move( appSettings->HUDX(), appSettings->HUDY() ); } }
void SettingsWindow::InitTable() { auto appSettings(GetAppSettings().lock()); assert(appSettings); Gtk::ComboBoxEntryText* cb = new Gtk::ComboBoxEntryText; f_table.AddItem( InitDie, gettext("Initiative Dice (default: 1d20)"), false, cb, NULL ); f_tooltips.set_tip( *cb, gettext("Die value used to roll Initiative internally. 1d20 is the default, but you may enter other values such as 2d10.") ); Gtk::Adjustment* adj = new Gtk::Adjustment(0.0, g_lower_range, g_upper_range); Gtk::SpinButton* sp = new Gtk::SpinButton( *adj ); f_table.AddItem( DeathThreshold, gettext("Death Threshold"), false, sp, NULL ); sp->set_numeric( true ); f_tooltips.set_tip( *sp, gettext("Hitpoint threshold value below 0 that indicates combatant death (default is -10).") ); Gtk::FontButton* fb = new Gtk::FontButton( appSettings->CombatantListFont() ); f_table.AddItem( CharListFont, gettext("Main Combatant List Font"), false, fb, NULL ); f_tooltips.set_tip( *fb, gettext("Select the font to use for the main combatant list. Requires application restart.") ); fb = new Gtk::FontButton( appSettings->AltCombatantListFont() ); f_table.AddItem( AltCharListFont, gettext("Alternate Combatant List Font (for players)"), false, fb, NULL ); f_tooltips.set_tip( *fb, gettext("Select the font to use for the player view combatant list. Requires application restart.") ); }
ClearSortTransaction::ClearSortTransaction() { f_prevDC = GetAppSettings().lock()->LastDC(); f_sortId = GetCharacterModel().lock()->getSoftSort(); }
void SortTransaction::doit() { GetAppSettings().lock()->LastDC ( f_dc ); GetCharacterModel().lock()->setSoftSort( f_sortId ); }
// --------------------------------------------------------------------- BOOL WinCoveredCalcApp::initInstance() { bool langFileLoaded = false; if (!base::initInstance()) { return FALSE; } // コモンコントロール初期化 ::InitCommonControls(); // レイヤードウィンドウ関連の API apiLayeredWindow.Initialize(); // ウェイトカーソルを取得しておく waitCursor = ::LoadCursor(NULL, IDC_WAIT); // モニタ情報を取得しておく monitorInfo.Update(); // ベースクラス初期化 if (!init()) { return FALSE; } // コマンドラインパラメータ解析 CommandLineParam* clParam = GetCommandLineParam(); clParam->SetParameter(__argc, __targv); // 言語ファイルの読み込み if (clParam->IsLangFileSpecified()) { try { loadLangFile(clParam->GetLangFile()); langFileLoaded = true; } catch (Exception* ex) { ex->Delete(); // コマンドラインパラメータで指定された言語ファイルが読み込めなかったので無視します。 DoMessageBox(NSID_EMSG_LOAD_COMMANDLINE_LANGFILE, MessageBoxProvider::ButtonType_OK, MessageBoxProvider::AlertType_Warning); } } // ウィンドウクラスの登録 WinMainWindow::RegisterClass(); //設定ファイルを準備 Path settingFile; if (clParam->IsSettingFileSpecified()) { // コマンドラインで設定ファイルが指定されていればそれを使う settingFile.Assign(clParam->GetSettingFile()); } else { // デフォルト設定ファイルを使う try { readyDefaultSettingFilePath(settingFile); } catch (Exception* ex) { ExceptionMessageUtils::DoExceptionMessageBoxWithText(this, ex, NSID_EMSG_READY_DEFAULT_SETTING_FILE, MessageBoxProvider::ButtonType_OK, MessageBoxProvider::AlertType_Stop); ex->Delete(); return FALSE; } } // 設定の読み込み try { loadSettings(settingFile); } catch (Exception* ex) { ex->Delete(); return FALSE; } // 設定に保存された言語ファイルを読み込む if (!langFileLoaded) { AppSettings* appSettings = GetAppSettings(); const Path settingPath = appSettings->GetLanguageFilePath(); if (!settingPath.IsEmpty()) { Path langFileFullPath = MakeAbsoluteLangFilePath(settingPath); if (!langFileFullPath.IsEmpty()) { try { loadLangFile(langFileFullPath); langFileLoaded = true; } catch (Exception* ex) { ex->Delete(); // 設定ファイルに書かれた言語ファイルが読めません。 DoMessageBox(NSID_EMSG_LOAD_SETTING_LANGFILE, MessageBoxProvider::ButtonType_OK, MessageBoxProvider::AlertType_Warning); } } } } if (!langFileLoaded) { // 設定に保存されていなければ、ユーザーに問い合わせる WinSelectLanguageDlg selectLangDlg; try { selectLangDlg.SetRelativeLangFilePath(Path(ALITERAL("enUS.cclxw"))); int dlgResult = selectLangDlg.DoModal(NULL); if (IDOK != dlgResult) { return FALSE; } } catch (Exception* ex) { ExceptionMessageUtils::DoExceptionMessageBox(this, ex); ex->Delete(); return FALSE; } Path langFilePath = selectLangDlg.GetRelativeLangFilePath(); Path langFileFullPath = MakeAbsoluteLangFilePath(langFilePath); if (!langFileFullPath.IsEmpty()) { try { loadLangFile(langFileFullPath); langFileLoaded = true; GetAppSettings()->SetLanguageFilePath(langFilePath); } catch (Exception* ex) { ex->Delete(); // 言語ファイルが読めません。 DoMessageBox(NSID_EMSG_LOAD_LANGFILE, MessageBoxProvider::ButtonType_OK, MessageBoxProvider::AlertType_Warning); } } } // キー定義名 DB のロード loadKeyNameDB(); // キーマッピング読み込み loadKeyMappingsOnInit(); // カバー読み込み try { AppSettings* appSettings = GetAppSettings(); loadCoverDef(appSettings->GetBaseFolder(), appSettings->GetLastCoverDef(), appSettings->GetLastCoverNo()); } catch (Exception* ex) { ExceptionMessageUtils::DoExceptionMessageBox(this, ex); ex->Delete(); // デフォルトカバーで復活を試みる if (!restoreByDefaultCoverDef()) { // ダメでした…。 return FALSE; } } // メインウィンドウ生成 DWORD exStyle = 0; if (GetAppSettings()->IsMainWindowAlwaysOnTop()) { exStyle = WS_EX_TOPMOST; } const Point32& lastMainWindowPos = GetAppSettings()->GetLastMainWindowPos(); if (!mainWindow.CreateEx(exStyle, WinMainWindow::GetWindowClassName(), ALITERAL("CoveredCalc"), WS_SYSMENU | WS_POPUP | WS_MINIMIZEBOX, lastMainWindowPos.x, lastMainWindowPos.y, 0, 0, NULL, NULL)) { // デフォルトカバーにして再チャレンジ bool restored = false; if (restoreByDefaultCoverDef()) { if (mainWindow.CreateEx(exStyle, WinMainWindow::GetWindowClassName(), ALITERAL("CoveredCalc"), WS_SYSMENU | WS_POPUP | WS_MINIMIZEBOX, lastMainWindowPos.x, lastMainWindowPos.y, 0, 0, NULL, NULL)) { restored = true; } } if (!restored) { DoMessageBox(NSID_EMSG_CREATE_MAIN_WINDOW, MessageBoxProvider::ButtonType_OK, MessageBoxProvider::AlertType_Stop); return FALSE; } } ::ShowWindow(mainWindow.m_hWnd, SW_SHOW); // カバーブラウザ生成 Path baseFolderPath = GetAppSettings()->GetBaseFolder(); if (baseFolderPath.IsEmpty()) { baseFolderPath = getAppFolderPath(); } coverBrowser.SetCoversFolderPath(baseFolderPath.Append(ALITERAL("Covers"))); if (!coverBrowser.Create(NULL)) { DoMessageBox(NSID_EMSG_CREATE_COVER_BROWSER, MessageBoxProvider::ButtonType_OK, MessageBoxProvider::AlertType_Stop); } ::ShowWindow(mainWindow.m_hWnd, SW_SHOW); if (GetAppSettings()->IsCoverBrowserVisible()) { ::ShowWindow(coverBrowser.m_hWnd, SW_SHOW); } ::SetForegroundWindow(mainWindow.m_hWnd); return TRUE; }
void ClearSortTransaction::doit() { GetAppSettings().lock()->LastDC ( -1 ); GetCharacterModel().lock()->setSoftSort( molib::moName("NONE") ); }
void ClearSortTransaction::undo() { GetAppSettings().lock()->LastDC ( f_prevDC ); GetCharacterModel().lock()->setSoftSort( f_sortId ); }
void CPrefsDlg::OnCancel (void) { GetAppSettings (); UpdateData (FALSE); }