QColor GeneralConfig::getMarginsBackground() { /* -returns backgroung color for margins (line numbering etc.) */ //get data from config file QString colorString = getConfigData( getConfigFilePath("config/theme.conf"), "Editor", "margins-background"); //process and return value QColor c = getColorFromString(colorString); if ( c.isValid() ) return c; else return QColor(200,200,200); }
QColor GeneralConfig::getValueAsColor(const QString& key, const QString& subKey_1, const QString& subKey_2) const { /* -get the value that corresponds to the given keys and return it as a color value -an empty color is returned if the value is not a valid color string */ QString colorString = getValue(key, subKey_1, subKey_2).toString(); //get the configured value using the keys return getColorFromString( colorString ); //convert the value to a color and return it }
QColor GeneralConfig::getWhiteSpaceColor() { /* -returns color of white space when visible in editor */ //get data from config file QString colorString = getConfigData( getConfigFilePath("config/theme.conf"), "Editor", "whitespace-color"); //process and return value QColor c = getColorFromString(colorString); if ( c.isValid() ) return c; else return QColor(255,255,255); }
QColor GeneralConfig::getMarginsForeground() { /* -returns foreground color for margins (line numbering etc.) */ //get data from config file QString colorString = getConfigData( getConfigFilePath("config/theme.conf"), "Editor", "margins-foreground"); //process and return value QColor c = getColorFromString(colorString); //QColor c = getValueAsColor("editor_theme", "paper_color"); if ( c.isValid() ) return c; else return QColor(0,0,0); }
void Load() { std::string filepath = Utilities::getExecPath(DEF_INITNAME); GError *error = NULL; GKeyFile *key_file = g_key_file_new(); gboolean found = g_key_file_load_from_file(key_file, filepath.c_str(), GKeyFileFlags::G_KEY_FILE_NONE, &error); if (found) { if (error) { g_critical("Load configuration fails! %s\n", error->message); g_error_free(error); error = NULL; g_key_file_free(key_file); return; } } m_autohide = g_key_file_get_boolean(key_file, "DockLight", "Autohide", &error); if (error) { g_critical("configuration Key (Autohide) could not be found!! %s\n", error->message); g_error_free(error); error = NULL; g_key_file_free(key_file); return; } char* themename = g_key_file_get_string(key_file, "DockLight", "Theme", &error); if (themename == NULL) { if (error) { //g_print("configuration Key (Theme) could not be found. use default\n"); g_error_free(error); error = NULL; } g_key_file_free(key_file); return; } bool panelScaleOnHover = g_key_file_get_boolean(key_file, themename, "PanelScaleOnHover", &error); if (error) { //g_print("configuration Key (Theme PanelScaleOnHover) could not be found. use default\n"); g_error_free(error); error = NULL; panelScaleOnHover = false; } int panelLinesBinaryValue = g_key_file_get_integer(key_file, themename, "PanelLinesBinaryValue", &error); if (error) { //g_print("configuration Key (Theme %s PanelLinesBinaryValue ) could not be found. use default\n", themename); g_error_free(error); error = NULL; } int panelSelectorLinesBinaryValue = g_key_file_get_integer(key_file, themename, "PanelSelectorLinesBinaryValue", &error); if (error) { //g_print("configuration Key (Theme %s PanelSelectorLinesBinaryValue ) could not be found. use default\n", themename); g_error_free(error); error = NULL; } int previewlLinesBinaryValue = g_key_file_get_integer(key_file, themename, "PreviewLinesBinaryValue", &error); if (error) { //g_print("configuration Key (Theme %s PreviewLinesBinaryValue ) could not be found. use default\n", themename); g_error_free(error); error = NULL; } int previewSelectorLinesBinaryValue = g_key_file_get_integer(key_file, themename, "PreviewSelectorLinesBinaryValue", &error); if (error) { //g_print("configuration Key (Theme %s PreviewSelectorLinesBinaryValue ) could not be found. use default\n", themename); g_error_free(error); error = NULL; } char* windowString = g_key_file_get_string(key_file, themename, "Window", &error); if (windowString == NULL) { if (error) { // g_print("configuration Key (Theme %s Window ) could not be found. use default\n", themename); g_error_free(error); error = NULL; } } char* panelString = g_key_file_get_string(key_file, themename, "Panel", &error); if (panelString == NULL) { if (error) { //g_print("configuration Key (Theme %s Panel ) could not be found. use default\n", themename); g_error_free(error); error = NULL; } } char* PanelTitleString = g_key_file_get_string(key_file, themename, "PanelTitle", &error); if (PanelTitleString == NULL) { if (error) { //g_print("configuration Key (Theme %s PanelTitle ) could not be found. use default\n", themename); g_error_free(error); error = NULL; } } char* PanelTitleTextString = g_key_file_get_string(key_file, themename, "PanelTitleText", &error); if (PanelTitleTextString == NULL) { if (error) { //g_print("configuration Key (Theme %s PanelTitleText ) could not be found. use default\n", themename); g_error_free(error); error = NULL; } } char* previewString = g_key_file_get_string(key_file, themename, "Preview", &error); if (previewString == NULL) { if (error) { //g_print("configuration Key (Theme %s Preview ) could not be found. use default\n", themename); g_error_free(error); error = NULL; } } char* PanelSelectorString = g_key_file_get_string(key_file, themename, "PanelSelector", &error); if (PanelSelectorString == NULL) { if (error) { //g_print("configuration Key (Theme %s PanelSelector ) could not be found. use default\n", themename); g_error_free(error); error = NULL; } } char* PreviewTitleTextString = g_key_file_get_string(key_file, themename, "PreviewTitleText", &error); if (PreviewTitleTextString == NULL) { if (error) { //g_print("configuration Key (Theme %s PreviewTitleText ) could not be found. use default\n", themename); g_error_free(error); error = NULL; } } char* PreviewSelectorString = g_key_file_get_string(key_file, themename, "PreviewSelector", &error); if (PreviewSelectorString == NULL) { if (error) { //g_print("configuration Key (Theme %s PreviewSelector ) could not be found. use default\n", themename); g_error_free(error); error = NULL; } } bool enable; double lineWidth; double roundedRadius; Color background; Color foreground; m_theme.setPanelScaleOnhover(panelScaleOnHover); if (windowString != NULL) { getColorFromString(windowString, enable, lineWidth, roundedRadius, background, foreground); m_theme.forWindow().set(enable, background, foreground, lineWidth, roundedRadius); } if (panelString != NULL) { getColorFromString(panelString, enable, lineWidth, roundedRadius, background, foreground); m_theme.forPanel().set(enable, background, foreground, lineWidth, roundedRadius); } if (PanelTitleString != NULL) { getColorFromString(PanelTitleString, enable, lineWidth, roundedRadius, background, foreground); m_theme.forPanelTitle().set(enable, background, foreground, lineWidth, roundedRadius); } if (PanelTitleTextString != NULL) { getColorFromString(PanelTitleTextString, enable, lineWidth, roundedRadius, background, foreground); m_theme.forPanelTitleText().set(enable, background, foreground, lineWidth, roundedRadius); } if (previewString != NULL) { getColorFromString(previewString, enable, lineWidth, roundedRadius, background, foreground); m_theme.forPreview().set(enable, background, foreground, lineWidth, roundedRadius); } if (PanelSelectorString != NULL) { getColorFromString(PanelSelectorString, enable, lineWidth, roundedRadius, background, foreground); m_theme.forPanelSelector().set(enable, background, foreground, lineWidth, roundedRadius); } if (PreviewTitleTextString != NULL) { getColorFromString(PreviewTitleTextString, enable, lineWidth, roundedRadius, background, foreground); m_theme.forPreviewTitleText().set(enable, background, foreground, lineWidth, roundedRadius); } if (PreviewSelectorString != NULL) { getColorFromString(PreviewSelectorString, enable, lineWidth, roundedRadius, background, foreground); m_theme.forPreviewSelector().set(enable, background, foreground, lineWidth, roundedRadius); } m_theme.setPanelBinaryValue(panelLinesBinaryValue); m_theme.setPanelSelectorBinaryValue(panelSelectorLinesBinaryValue); m_theme.setPreviewBinaryValue(previewlLinesBinaryValue); m_theme.setPreviewSelectorBinaryValue(previewSelectorLinesBinaryValue); g_key_file_free(key_file); return; }
void CNativeToolbar::createToolbar(rho_param *p) { if (!rho_rhodesapp_check_mode() || !rho_wmsys_has_touchscreen() ) return; int bar_type = TOOLBAR_TYPE; m_rgbBackColor = RGB(220,220,220); m_rgbMaskColor = RGB(255,255,255); m_nHeight = MIN_TOOLBAR_HEIGHT; rho_param *params = NULL; switch (p->type) { case RHO_PARAM_ARRAY: params = p; break; case RHO_PARAM_HASH: { for (int i = 0, lim = p->v.hash->size; i < lim; ++i) { const char *name = p->v.hash->name[i]; rho_param *value = p->v.hash->value[i]; if (strcasecmp(name, "background_color") == 0) m_rgbBackColor = getColorFromString(value->v.string); else if (strcasecmp(name, "mask_color") == 0) m_rgbMaskColor = getColorFromString(value->v.string); else if (strcasecmp(name, "view_height") == 0) m_nHeight = atoi(value->v.string); else if (strcasecmp(name, "buttons") == 0 || strcasecmp(name, "tabs") == 0) params = value; } } break; default: { LOG(ERROR) + "Unexpected parameter type for create_nativebar, should be Array or Hash"; return; } } if (!params) { LOG(ERROR) + "Wrong parameters for create_nativebar"; return; } int size = params->v.array->size; if ( size == 0 ) { removeToolbar(); return; } if ( m_hWnd ) { removeAllButtons(); }else { RECT rcToolbar; rcToolbar.left = 0; rcToolbar.right = 0; rcToolbar.top = 0; rcToolbar.bottom = m_nHeight; Create(getAppWindow().m_hWnd, rcToolbar, NULL, WS_CHILD|CCS_NOPARENTALIGN|CCS_NORESIZE|CCS_NOMOVEY|CCS_BOTTOM|CCS_NODIVIDER | TBSTYLE_FLAT |TBSTYLE_LIST|TBSTYLE_TRANSPARENT ); //TBSTYLE_AUTOSIZE SetButtonStructSize(); } for (int i = 0; i < size; ++i) { rho_param *hash = params->v.array->value[i]; if (hash->type != RHO_PARAM_HASH) { LOG(ERROR) + "Unexpected type of array item for create_nativebar, should be Hash"; return; } const char *label = NULL; const char *action = NULL; const char *icon = NULL; const char *colored_icon = NULL; int nItemWidth = 0; for (int j = 0, lim = hash->v.hash->size; j < lim; ++j) { const char *name = hash->v.hash->name[j]; rho_param *value = hash->v.hash->value[j]; if (value->type != RHO_PARAM_STRING) { LOG(ERROR) + "Unexpected '" + name + "' type, should be String"; return; } if (strcasecmp(name, "label") == 0) label = value->v.string; else if (strcasecmp(name, "action") == 0) action = value->v.string; else if (strcasecmp(name, "icon") == 0) icon = value->v.string; else if (strcasecmp(name, "colored_icon") == 0) colored_icon = value->v.string; else if (strcasecmp(name, "width") == 0) nItemWidth = atoi(value->v.string); } if (label == NULL && bar_type == TOOLBAR_TYPE) label = ""; if ( label == NULL || action == NULL) { LOG(ERROR) + "Illegal argument for create_nativebar"; return; } if ( strcasecmp(action, "forward") == 0 && rho_conf_getBool("jqtouch_mode") ) continue; m_arButtons.addElement( new CToolbarBtn(label, action, icon, nItemWidth) ); } CSize sizeMax = getMaxImageSize(); m_nHeight = max(m_nHeight, sizeMax.cy+MIN_TOOLBAR_IDENT); int nBtnSize = m_nHeight-MIN_TOOLBAR_IDENT; SetButtonSize(max(nBtnSize,sizeMax.cx), max(nBtnSize,sizeMax.cy)); SetBitmapSize(sizeMax.cx, sizeMax.cy); m_listImages.Create(sizeMax.cx, sizeMax.cy, ILC_MASK|ILC_COLOR32, m_arButtons.size(), 0); SetImageList(m_listImages); for ( int i = 0; i < (int)m_arButtons.size(); i++ ) addToolbarButton( *m_arButtons.elementAt(i), i ); AutoSize(); alignSeparatorWidth(); ShowWindow(SW_SHOW); #if defined (OS_WINDOWS) RECT rcWnd; getAppWindow().GetWindowRect(&rcWnd); getAppWindow().SetWindowPos( 0, 0,0,rcWnd.right-rcWnd.left-1,rcWnd.bottom-rcWnd.top, SWP_NOMOVE|SWP_NOZORDER|SWP_FRAMECHANGED); getAppWindow().SetWindowPos( 0, 0,0,rcWnd.right-rcWnd.left,rcWnd.bottom-rcWnd.top, SWP_NOMOVE|SWP_NOZORDER|SWP_FRAMECHANGED); #else getAppWindow().SetWindowPos( 0, 0,0,0,0, SWP_NOMOVE|SWP_NOZORDER|SWP_NOSIZE|SWP_FRAMECHANGED); #endif }
bool getGameSetting() { xaeResourceBody tagRB; #ifndef __JP bool bRes = xae::Instance().get_resource_mgr()->get_resource_bin("media/setting.cfg", tagRB); #else bool bRes = xae::Instance().get_resource_mgr()->get_resource_bin("media/setting-jp.cfg", tagRB); #endif if(!bRes) return false; /** 配置文件 */ CCFGReader reader; reader.SetFile((char*)tagRB.m_pRes, tagRB.m_nSize); /** 系统相关 */ g_Setting.System.m_szGameTitle = reader.GetString("GAME_TITLE"); /** 文件相关 */ g_Setting.File.m_szScriptFile = reader.GetString("AVG_SCRIPT_FILE"); g_Setting.File.m_szBGPath = reader.GetString("AVG_BG_PATH"); g_Setting.File.m_szBGMPath = reader.GetString("AVG_BGM_PATH"); g_Setting.File.m_szMaidDrawPath = reader.GetString("AVG_MAID_DRAW_PATH"); g_Setting.File.m_szVoicePath = reader.GetString("AVG_VOICE_PATH"); g_Setting.File.m_szLevelPath = reader.GetString("LEVEL_PATH"); g_Setting.File.m_szVideoPath = reader.GetString("VIDEO_PATH"); g_Setting.File.m_szTempPath = reader.GetString("TEMP_PATH"); /** LOGO界面 */ g_Setting.Logo.m_fLogoFadeTimer = reader.GetFloat("LOGO_FADE_TIMER"); g_Setting.Logo.m_fLogoPauseTimer = reader.GetFloat("LOGO_PAUSE_TIMER"); /** AVG相关 */ g_Setting.AVG.m_fTextPerTimer = reader.GetFloat("TEXT_CHAR_PER_TIMER"); g_Setting.AVG.m_nTextboxLeft = reader.GetInt("TEXTBOX_RECT_LEFT"); g_Setting.AVG.m_nTextboxRight = reader.GetInt("TEXTBOX_RECT_RIGHT"); g_Setting.AVG.m_nTextboxTop = reader.GetInt("TEXTBOX_RECT_TOP"); g_Setting.AVG.m_nTextboxBottom = reader.GetInt("TEXTBOX_RECT_BOTTOM"); g_Setting.AVG.m_nTalkerLeft = reader.GetInt("TALKER_RECT_LEFT"); g_Setting.AVG.m_nTalkerRight = reader.GetInt("TALKER_RECT_RIGHT"); g_Setting.AVG.m_nTalkerTop = reader.GetInt("TALKER_RECT_TOP"); g_Setting.AVG.m_dwTalkerColor = getColorFromString(reader.GetString("TALKER_COLOR")); g_Setting.AVG.m_nTalkerSize = reader.GetInt("TALKER_SIZE"); g_Setting.AVG.m_nTextLeft = reader.GetInt("TEXT_POS_LEFT"); g_Setting.AVG.m_nTextTop = reader.GetInt("TEXT_POS_TOP"); g_Setting.AVG.m_nTextMaxPerLine = reader.GetInt("MAX_TEXT_NUM_PER_LINE"); g_Setting.AVG.m_dwTextColor = getColorFromString(reader.GetString("TEXT_COLOR")); g_Setting.AVG.m_nTextSize = reader.GetInt("TEXT_SIZE"); /** 砖块相关 */ g_Setting.Block.m_nBlockWidth = reader.GetInt("BLOCK_WIDTH"); g_Setting.Block.m_nBlockHeight = reader.GetInt("BLOCK_HEIGHT"); g_Setting.Block.m_nBlockRowCount = reader.GetInt("BLOCK_ROW_COUNT"); g_Setting.Block.m_nBlockColCount = reader.GetInt("BLOCK_COL_COUNT"); g_Setting.Block.m_nBallLength = reader.GetInt("BALL_LENGTH"); g_Setting.Block.m_fFlapY = reader.GetFloat("FLAP_Y"); g_Setting.Block.m_nFlapLength = reader.GetInt("FLAP_LENGTH"); g_Setting.Block.m_fTreasureMaxSpeed = reader.GetFloat("TREASURE_MAX_SPEED"); g_Setting.Block.m_fTreasureMinSpeed = reader.GetFloat("TREASURE_MIN_SPEED"); g_Setting.Block.m_fTreasureTimer = reader.GetFloat("TREASURE_TIME"); g_Setting.Block.m_fTreasureSpeedScale = reader.GetFloat("SPEED_PER_SCALE"); g_Setting.Block.m_nTreasureProb = reader.GetFloat("TREASURE_PROB"); g_Setting.Block.m_fFlapSpeed = reader.GetFloat("FLAP_SPEED"); g_Setting.Block.m_fBallSpeed = reader.GetFloat("BALL_SPEED"); g_Setting.Block.m_szPreBoss = reader.GetString("PRE_BOSS"); g_Setting.Block.m_fMaxHorizontalRate= reader.GetFloat("MAX_HORIZONTAL_RATE"); return true; }