void C3DSModel::ApplyMaterial(const char * matname) { MaterialInfo* mat = NULL; printf("Apply %s\n", matname); if (m_matdictExtra.find(matname) != m_matdictExtra.end()) { mat = m_matdictExtra[matname]; } else if (m_matdict.find(matname) != m_matdict.end()) { mat = m_matdict[matname]; } else { MessageBox(GetWindow(), "Material not exists", "error", 0); } if (m_curMesh != NULL && mat != NULL) { CImage2D * image = mat->texture == "" ? NULL : LoadGameImage(mat->texture); if (image) { m_curMesh->SetTexture(image->GetTexture()); } m_curMesh->SetDiffuse(mat->r, mat->g, mat->b, mat->materialType); } }
/////////////////// // Apply the given node void CImageButton::ApplyTag(xmlNodePtr node) { CWidget::ApplyTag(node); sPath = xmlGetString(node, "src", sPath); if (sPath.size()) bmpImage = LoadGameImage(sPath, true); }
//////////////// // Apply the given selector void CImageButton::ApplySelector(const CSSParser::Selector &sel, const std::string& prefix) { CWidget::ApplySelector(sel, prefix); // Go through the attributes for (std::list<CSSParser::Attribute>::const_iterator it = sel.getAttributes().begin(); it != sel.getAttributes().end(); it++) { if (it->getName() == "image") { sPath = JoinPaths(sel.getBaseURL(), it->getFirstValue().getURL()); bmpImage = LoadGameImage(sPath, true); } } }
////////////////// // Apply the given selector to the column void CListviewColumn::CColumnStyle::ApplySelector(const CSSParser::Selector& sel, const std::string& prefix) { cBackground.ApplySelector(sel, prefix); cBorder.ApplySelector(sel, prefix); cFont.ApplySelector(sel, prefix); cText.ApplySelector(sel, prefix); // Go through the attributes FOR_EACH_ATTRIBUTE(sel, it) { if (it->getName() == prefix + "arrow-image") bmpSortArrow.set(LoadGameImage(JoinPaths(sel.getBaseURL(), it->getFirstValue().getURL()), true), it->getPriority()); } }
/////////////////// // Apply the given tag void CScrollbar::ApplyTag(xmlNodePtr node) { CWidget::ApplyTag(node); iMin = MAX(0, xmlGetInt(node, "min")); iMax = MAX(iMin + 1, xmlGetInt(node, "max", iMin + 1)); iValue = CLAMP(xmlGetInt(node, "value"), iMin, iMax); iItemsperbox = CLAMP(xmlGetInt(node, "itemsperbox"), 0, iMax); std::string base = xmlGetBaseURL(node); if (xmlPropExists(node, "topbtn")) bmpTop.set(LoadGameImage(JoinPaths(base, xmlGetString(node, "topbtn"))), TAG_ATTR_PRIORITY); if (xmlPropExists(node, "bottombtn")) bmpBottom.set(LoadGameImage(JoinPaths(base, xmlGetString(node, "bottombtn"))), TAG_ATTR_PRIORITY); if (xmlPropExists(node, "slidertop")) bmpSliderTop.set(LoadGameImage(JoinPaths(base, xmlGetString(node, "slidertop"))), TAG_ATTR_PRIORITY); if (xmlPropExists(node, "sliderbottom")) bmpSliderBottom.set(LoadGameImage(JoinPaths(base, xmlGetString(node, "sliderbottom"))), TAG_ATTR_PRIORITY); if (xmlPropExists(node, "slidermain")) bmpSliderMiddle.set(LoadGameImage(JoinPaths(base, xmlGetString(node, "slidermain"))), TAG_ATTR_PRIORITY); if (xmlPropExists(node, "color")) iColor.set(xmlGetColour(node, "color", iColor), TAG_ATTR_PRIORITY); if (xmlPropExists(node, "highcolor")) iHighlightColor.set(xmlGetColour(node, "highcolor", iHighlightColor), TAG_ATTR_PRIORITY); if (xmlPropExists(node, "shadowcolor")) iShadowColor.set(xmlGetColour(node, "shadowcolor", iShadowColor), TAG_ATTR_PRIORITY); if (xmlPropExists(node, "bgcolor")) iBackgroundColor.set(xmlGetColour(node, "bgcolor", iBackgroundColor), TAG_ATTR_PRIORITY); if (xmlPropExists(node, "arrowcolor")) iArrowColor.set(xmlGetColour(node, "arrowcolor", iArrowColor), TAG_ATTR_PRIORITY); if (xmlPropExists(node, "dir")) { std::string dir = xmlGetString(node, "dir", "vertical"); if (stringcaseequal(dir, "vertical")) iDirection.set(scrVertical, TAG_ATTR_PRIORITY); else if (stringcaseequal(dir, "horizontal")) iDirection.set(scrHorizontal, TAG_ATTR_PRIORITY); } }
/////////////////// // Apply a selector to one border side void CBorder::ApplySelectorToBorder(const CSSParser::Selector &sel, const std::string &prefix, const std::string &side, CBorder::BorderLineSettings &sett) { bool fail = false; std::string att = prefix + "border-" + side; FOR_EACH_ATTRIBUTE(sel, it) { if (it->getName() == att + "color" || it->getName() == att + "light" || it->getName() == "colour") { sett.clLight.set(it->getFirstValue().getColor(sett.clLight), it->getPriority()); sett.clDark.set(sett.clLight, it->getPriority()); } else if (it->getName() == att + "dark") { sett.clDark.set(it->getFirstValue().getColor(sett.clDark), it->getPriority()); } else if (it->getName() == att + "size") { sett.iThickness.set(it->getFirstValue().getInteger(0), it->getPriority()); } else if (it->getName() == att + "style") { sett.iStyle.set(StringToBorderStyle(it->getFirstValue().getString(), fail), it->getPriority()); } else if (it->getName() == att + "image") { sett.bmpLine.set(LoadGameImage(JoinPaths(sel.getBaseURL(), it->getFirstValue().getURL())), it->getPriority()); } else if (it->getName() == prefix + "border") { bool thickness_set = false; for (std::vector<CSSParser::Attribute::Value>::const_iterator val = it->getParsedValue().begin(); val != it->getParsedValue().end(); val++) { // Style BorderStyle style = StringToBorderStyle(val->getString(), fail); if (!fail) { sett.iStyle.set(style, it->getPriority()); if (!thickness_set) sett.iThickness.set(MAX(1, (int)sett.iThickness), it->getPriority()); // for example "border: solid black" means "1px solid black" continue; } // Thickness int thick = from_string<int>(val->getString(), fail); if (!fail && thick >= 0) { thickness_set = true; sett.iThickness.set(thick, it->getPriority()); } // Color Color c = StrToCol(val->getString(), fail); if (!fail) { sett.clDark.set(c, it->getPriority()); sett.clLight.set(c, it->getPriority()); } } } } }
/////////////////////// // Apply a selector to the scrollbar void CScrollbar::ApplySelector(const CSSParser::Selector &sel, const std::string &prefix) { CWidget::ApplySelector(sel, prefix); const std::string& base = sel.getBaseURL(); FOR_EACH_ATTRIBUTE(sel, it) { if (it->getName() == prefix + "top-button") { bmpTop.set(LoadGameImage(JoinPaths(base, it->getFirstValue().getURL()), true), it->getPriority()); } else if (it->getName() == prefix + "bottom-button") { bmpBottom.set(LoadGameImage(JoinPaths(base, it->getFirstValue().getURL()), true), it->getPriority()); } else if (it->getName() == prefix + "background-image") { bmpBackground.set(LoadGameImage(JoinPaths(base, it->getFirstValue().getURL())), it->getPriority()); } else if (it->getName() == prefix + "slider-top-image") { bmpSliderTop.set(LoadGameImage(JoinPaths(base, it->getFirstValue().getURL())), it->getPriority()); } else if (it->getName() == prefix + "slider-bottom-image") { bmpSliderBottom.set(LoadGameImage(JoinPaths(base, it->getFirstValue().getURL())), it->getPriority()); } else if (it->getName() == prefix + "slider-main-image") { bmpSliderMiddle.set(LoadGameImage(JoinPaths(base, it->getFirstValue().getURL())), it->getPriority()); } else if (it->getName() == prefix + "face-color" || it->getName() == prefix + "face-colour") { iColor.set(it->getFirstValue().getColor(iColor), it->getPriority()); } else if (it->getName() == prefix + "background-color" || it->getName() == prefix + "background-colour") { iBackgroundColor.set(it->getFirstValue().getColor(iBackgroundColor), it->getPriority()); } else if (it->getName() == prefix + "highlight-color" || it->getName() == prefix + "highlight-colour") { iHighlightColor.set(it->getFirstValue().getColor(iHighlightColor), it->getPriority()); } else if (it->getName() == prefix + "shadow-color" || it->getName() == prefix + "shadow-colour") { iShadowColor.set(it->getFirstValue().getColor(iShadowColor), it->getPriority()); } else if (it->getName() == prefix + "arrow-color" || it->getName() == prefix + "arrow-colour") { iArrowColor.set(it->getFirstValue().getColor(iArrowColor), it->getPriority()); } else if (it->getName() == prefix + "direction") { if (it->getFirstValue().getString() == "vertical") iDirection.set(scrVertical, it->getPriority()); else if (it->getFirstValue().getString() == "horizontal") iDirection.set(scrHorizontal, it->getPriority()); else iDirection.set(scrVertical, DEFAULT_PRIORITY); // Defaults to vertical } } }
FOR_EACH_ATTRIBUTE(sel, it) { if (it->getName() == prefix + "border-radius-" + corner) sett.iRoundRadius.set(it->getFirstValue().getInteger(0), it->getPriority()); else if (it->getName() == prefix + "border-image-" + corner) sett.bmpCorner.set(LoadGameImage(JoinPaths(sel.getBaseURL(), it->getFirstValue().getURL())), it->getPriority()); }
/////////////////// // Initialize the standard Auxiliary Library int InitializeAuxLib(const std::string& config, int bpp, int vidflags) { // We have already loaded all options from the config file at this time. #ifdef linux //XInitThreads(); // We should call this before any SDL video stuff and window creation #endif ConfigFile=config; if(getenv("SDL_VIDEODRIVER")) notes << "SDL_VIDEODRIVER=" << getenv("SDL_VIDEODRIVER") << endl; // Solves problem with FPS in fullscreen #ifdef WIN32 if(!getenv("SDL_VIDEODRIVER")) { notes << "SDL_VIDEODRIVER not set, setting to directx" << endl; putenv((char*)"SDL_VIDEODRIVER=directx"); } #endif // Initialize SDL int SDLflags = SDL_INIT_TIMER | SDL_INIT_NOPARACHUTE; if(!bDedicated) { SDLflags |= SDL_INIT_VIDEO; } else { hints << "DEDICATED MODE" << endl; bDisableSound = true; bJoystickSupport = false; } if(SDL_Init(SDLflags) == -1) { errors << "Failed to initialize the SDL system!\nErrorMsg: " << std::string(SDL_GetError()) << endl; #ifdef WIN32 // retry it with any available video driver unsetenv("SDL_VIDEODRIVER"); if(SDL_Init(SDLflags) != -1) hints << "... but we have success with the any driver" << endl; // retry with windib else if(putenv((char*)"SDL_VIDEODRIVER=windib") == 0 && SDL_Init(SDLflags) != -1) hints << "... but we have success with the windib driver" << endl; else #endif return false; } #ifndef DISABLE_JOYSTICK if(bJoystickSupport) { if(SDL_InitSubSystem(SDL_INIT_JOYSTICK) != 0) { warnings << "WARNING: couldn't init joystick subystem: " << SDL_GetError() << endl; bJoystickSupport = false; } } #endif if(!bDedicated && !SetVideoMode()) return false; // Enable the system events SDL_EventState(SDL_SYSWMEVENT, SDL_ENABLE); SDL_EventState(SDL_VIDEOEXPOSE, SDL_ENABLE); // Enable unicode and key repeat SDL_EnableUNICODE(1); SDL_EnableKeyRepeat(200,20); /* Note about the different sound vars: bDisableSound - if the sound system+driver is disabled permanentely tLXOptions->bSoundOn - if the sound is enabled temporarely (false -> volume=0, nothing else) I.e., even with tLXOptions->bSoundOn=false (Audio.Enabled=false in config), the sound system will be loaded. To start OLX without the sound system, use the -nosound parameter. The console variable Audio.Enabled links to tLXOptions->bSoundOn. The console command 'sound' also wraps around tLXOptions->bSoundOn. tLXOptions->iSoundVolume will never be touched by OLX itself, only the user can modify it. tLXOptions->bSoundOn will also not be touched by OLX itself, only user actions can modify it. (Both points were somewhat broken earlier and kind of annoying.) */ if( !bDisableSound ) { // Initialize sound //if(!InitSoundSystem(22050, 1, 512)) { if(!InitSoundSystem(44100, 1, 512)) { warnings << "Failed the initialize the sound system" << endl; bDisableSound = true; } } if(bDisableSound) { notes << "soundsystem completly disabled" << endl; // NOTE: Don't change tLXOptions->bSoundOn here! } if( tLXOptions->bSoundOn ) { StartSoundSystem(); } else StopSoundSystem(); // Give a seed to the random number generator srand((unsigned int)time(NULL)); if(!bDedicated) { SmartPointer<SDL_Surface> bmpIcon = LoadGameImage("data/icon.png", true); if(bmpIcon.get()) SDL_WM_SetIcon(bmpIcon.get(), NULL); } InitEventQueue(); // Initialize the keyboard & mouse InitEventSystem(); // Initialize timers InitializeTimers(); #ifdef DEBUG // Cache InitCacheDebug(); #endif return true; }
/////////////////// // Create void CCheckbox::Create() { bmpImage = LoadGameImage("data/frontend/checkbox.png"); }