sc_signed bar() { sc_signed y(6); sc_unsigned yu(6); foo(y, yu); sc_signed z(10); sc_unsigned zu(10); foo(z, zu); sc_signed x(8); sc_unsigned xu(8); foo(x, xu); return x + y + z; }
bool ON_BrepFace::ChangeSurface( int si ) { if ( 0 == m_brep ) return false; if ( si < 0 || si >= m_brep->m_S.Count() ) return false; const ON_Surface* pSurface = m_brep->m_S[si]; m_brep->DestroyMesh( ON::any_mesh ); const ON_Surface* old_srf = SurfaceOf(); m_si = si; SetProxySurface(pSurface); if ( pSurface ) m_bbox = pSurface->BoundingBox(); else m_bbox.Destroy(); m_brep->m_bbox.Destroy(); if ( old_srf && pSurface ) { // If domain changed, tehn update 2d trim curve locations ON_Interval udom0 = old_srf->Domain(0); ON_Interval vdom0 = old_srf->Domain(1); ON_Interval udom1 = pSurface->Domain(0); ON_Interval vdom1 = pSurface->Domain(1); if ( udom0 != udom1 || vdom0 != vdom1 ) { // need to transform trimming curves ON_Xform x(1), xu(1), xv(1); if ( udom0 != udom1 ) xu.IntervalChange(0,udom0,udom1); if ( vdom0 != vdom1 ) xv.IntervalChange(1,vdom0,vdom1); x = xv*xu; TransformTrim(x); } int vcount0 = m_brep->m_V.Count(); // If singular points changed, then add/remove edges // and update trim.m_type flags int i; { bool bSing0[4]; bool bSing1[4]; for ( i = 0; i < 4; i++ ) { bSing0[i] = old_srf->IsSingular(i) ? true : false; bSing1[i] = pSurface->IsSingular(i) ? true : false; } int sing_fix, sing_fix_max = 1; for ( sing_fix = 0; sing_fix < sing_fix_max; sing_fix++ ) { // sing_fix: // 0: expands old singularities and checks for new ones // 1: collapses old edges to new singular points. for ( i = 0; i < 4; i++ ) { if ( bSing0[i] == bSing1[i] ) continue; ON_Surface::ISO iso = ON_Surface::not_iso; switch(i) { case 0: iso = ON_Surface::S_iso; break; case 1: iso = ON_Surface::E_iso; break; case 2: iso = ON_Surface::N_iso; break; case 3: iso = ON_Surface::W_iso; break; } if ( bSing0[i] && sing_fix != 0 ) { // we already expanded old singular trims into edge trims continue; } for ( int fli = 0; fli < m_li.Count(); fli++ ) { const ON_BrepLoop* loop = Loop(fli); if ( 0 == loop ) continue; if ( loop->m_type != ON_BrepLoop::outer ) continue; for ( int lti = 0; lti < loop->m_ti.Count(); lti++ ) { ON_BrepTrim* trim = loop->Trim(lti); if ( !trim ) continue; if ( trim->m_iso != iso ) continue; ON_BrepTrim* nexttrim = loop->Trim((lti+1)%loop->m_ti.Count()); if ( bSing0[i] ) { // valid singular trim changing to non-singular trim if( 0 == sing_fix ) ChangeTrimSingToBdry( *m_brep, *trim, nexttrim ); } else if ( bSing1[i] ) { if ( 0 == sing_fix ) { // we need a 2nd pass to collapse this edge // to a singular trim. sing_fix_max = 2; } else { // valid non-singular trim changing to singular trim ON_BrepTrim* prevtrim = loop->Trim((lti-1+loop->m_ti.Count())%loop->m_ti.Count()); ChangeTrimBdryToSing( *m_brep, *trim, prevtrim, nexttrim ); } } } } } } } // If closed/open status changed, then add/remove edges // and update m_type flag for ( i = 0; i < 2; i++ ) { bool bClosed0 = old_srf->IsClosed(i) ? true : false; bool bClosed1 = pSurface->IsClosed(i) ? true : false; if ( bClosed0 == bClosed1 ) continue; ON_Surface::ISO isoA = ON_Surface::not_iso; ON_Surface::ISO isoB = ON_Surface::not_iso; switch(i) { case 0: isoA = ON_Surface::W_iso; isoB = ON_Surface::E_iso; break; case 1: isoA = ON_Surface::S_iso; isoB = ON_Surface::N_iso; break; } for ( int fli = 0; fli < m_li.Count(); fli++ ) { const ON_BrepLoop* loop = Loop(fli); if ( 0 == loop ) continue; if ( loop->m_type != ON_BrepLoop::outer ) continue; int loop_trim_count = loop->m_ti.Count(); for ( int ltiA = 0; ltiA < loop_trim_count; ltiA++ ) { ON_BrepTrim* trimA = loop->Trim(ltiA); if ( !trimA ) continue; if ( trimA->m_iso != isoA ) continue; if ( bClosed0 ) { // old surface has a seam and new surface does not if ( trimA->m_type != ON_BrepTrim::seam ) continue; const ON_BrepEdge* edge = m_brep->Edge(trimA->m_ei); if ( 0 == edge ) continue; if ( edge->m_ti.Count() != 2 ) continue; int etiB = (edge->m_ti[0] == trimA->m_trim_index) ? 1 : 0; ON_BrepTrim* trimB = edge->Trim(etiB); if ( 0 == trimB ) continue; if ( trimA == trimB ) continue; if ( trimB->m_li != trimA->m_li ) continue; if ( trimB->m_type != ON_BrepTrim::seam ) continue; if ( trimB->m_iso != isoB ) continue; for ( int ltiB = 0; ltiB < loop_trim_count; ltiB++ ) { if ( trimB != loop->Trim(ltiB) ) continue; ON_BrepTrim* prevtrimB = loop->Trim((ltiB+loop_trim_count-1)%loop_trim_count); ON_BrepTrim* nexttrimB = loop->Trim((ltiB+1)%loop_trim_count); if ( 0 == prevtrimB ) continue; if ( 0 == nexttrimB ) continue; if ( prevtrimB == trimA || prevtrimB == trimB ) continue; if ( nexttrimB == trimA || nexttrimB == trimB ) continue; if ( prevtrimB == nexttrimB ) continue; SplitSeam( *m_brep, *trimA, *trimB, *prevtrimB, *nexttrimB, vcount0 ); break; } } else { // open sides replaced with a seam // TODO bool sok; sok = SealSeam(i, *this); if (sok) sok = !sok; } } } } } if ( pSurface ) { for ( int fli = 0; fli < m_li.Count(); fli++ ) { const ON_BrepLoop* loop = Loop(fli); if ( 0 == loop ) continue; for ( int lti = 0; lti < loop->m_ti.Count(); lti++ ) { const ON_BrepTrim* trim = loop->Trim(lti); if ( 0 == trim ) continue; ON_BrepVertex* v0 = m_brep->Vertex(trim->m_vi[0]); if ( 0 != v0 ) { if ( v0->point == ON_UNSET_POINT ) { ON_3dPoint uv = trim->PointAtStart(); v0->point = pSurface->PointAt( uv.x, uv.y ); } } } } } return true; }
void cChoiceManager::CreateChoiceBox(int x, int y, int width, int height, int ID, int numChoices, int itemHeight, int MaxStrLen, int fontsize) { DirPath dp = DirPath() << "Resources" << "Interface" << cfg.resolution.resolution() << "ChoiceBox.xml"; TiXmlDocument docChoiceBox(dp.c_str()); int a, b, c, d, e, f; if (docChoiceBox.LoadFile()) { //<Window Name = "ChoiceBox" XPos = "224" YPos = "127" Width = "352" Height = "160" RowHeight = "32" FontSize = "16" / > string m_filename = dp.c_str(); TiXmlElement *el, *root_el = docChoiceBox.RootElement(); for (el = root_el->FirstChildElement(); el; el = el->NextSiblingElement()) { XmlUtil xu(m_filename); xu.get_att(el, "XPos", a); xu.get_att(el, "YPos", b); xu.get_att(el, "Width", c); xu.get_att(el, "Height", d); xu.get_att(el, "RowHeight", e); xu.get_att(el, "FontSize", f); } if (a > 0) x = a; if (b > 0) y = b; if (c > 0) width = c; if (d > 0) height = d; if (e > 0) itemHeight = e; if (f > 0) fontsize = f; } cChoice* newChoice = 0; if (m_Font == 0) { m_Font = new cFont(); m_Font->LoadFont(cfg.fonts.normal(), fontsize); m_Font->SetText(""); m_Font->SetColor(0, 0, 0); } if (MaxStrLen == 0) { newChoice = new cChoice(); if ((height - 2) / itemHeight < numChoices) height = (numChoices*itemHeight) + 2; newChoice->m_NumDrawnElements = (height - 2) / itemHeight; newChoice->m_eWidth = (width - (18)); newChoice->m_eHeight = itemHeight; newChoice->m_NumChoices = numChoices; newChoice->m_CurrChoice = -1; newChoice->m_XPos = x; newChoice->m_YPos = y; newChoice->m_Width = width; newChoice->m_Height = height; newChoice->m_FontSize = fontsize; newChoice->m_Choices = new string[numChoices]; newChoice->m_ID = ID; newChoice->m_Border = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 32, 0, 0, 0, 0); SDL_FillRect(newChoice->m_Border, 0, SDL_MapRGB(newChoice->m_Border->format, 0, 0, 0)); newChoice->m_Background = SDL_CreateRGBSurface(SDL_SWSURFACE, width - (18), height - 2, 32, 0, 0, 0, 0); SDL_FillRect(newChoice->m_Background, 0, SDL_MapRGB(newChoice->m_Background->format, 88, 163, 113)); newChoice->m_ElementBackground = SDL_CreateRGBSurface(SDL_SWSURFACE, newChoice->m_eWidth, newChoice->m_eHeight, 32, 0, 0, 0, 0); SDL_FillRect(newChoice->m_ElementBackground, 0, SDL_MapRGB(newChoice->m_ElementBackground->format, 88, 163, 113)); newChoice->m_ElementSelectedBackground = SDL_CreateRGBSurface(SDL_SWSURFACE, newChoice->m_eWidth, newChoice->m_eHeight, 32, 0, 0, 0, 0); SDL_FillRect(newChoice->m_ElementSelectedBackground, 0, SDL_MapRGB(newChoice->m_ElementSelectedBackground->format, 229, 227, 52)); if (newChoice->m_eWidth > 120) newChoice->m_HeaderBackground = SDL_CreateRGBSurface(SDL_SWSURFACE, newChoice->m_eWidth, 32, 32, 0, 0, 0, 0); else newChoice->m_HeaderBackground = SDL_CreateRGBSurface(SDL_SWSURFACE, 120, 32, 32, 0, 0, 0, 0); SDL_FillRect(newChoice->m_HeaderBackground, 0, SDL_MapRGB(newChoice->m_HeaderBackground->format, 229, 227, 52)); } else // autosize and center according to the max string size, also shut off the scroll box if not needed { newChoice = new cChoice(); int MaxWidth = 0, MaxHeight = 0; string temp = "W"; for (int i = 0; i<MaxStrLen - 1; i++) temp += "W"; m_Font->GetSize(temp, MaxWidth, MaxHeight); int newHeight = (MaxHeight*numChoices) + 2; if (newHeight > g_Graphics.GetHeight()) newHeight = g_Graphics.GetHeight() - 34; if (MaxWidth > g_Graphics.GetWidth()) MaxWidth = g_Graphics.GetWidth() - 2; newChoice->m_NumDrawnElements = newHeight / MaxHeight; if (newChoice->m_NumDrawnElements >= numChoices) { newChoice->m_ScrollDisabled = true; newChoice->m_eWidth = (MaxWidth); } else newChoice->m_eWidth = (MaxWidth - (18)); newChoice->m_eHeight = MaxHeight; newChoice->m_NumChoices = numChoices; newChoice->m_CurrChoice = -1; newChoice->m_Width = MaxWidth; newChoice->m_Height = newHeight; newChoice->m_FontSize = fontsize; newChoice->m_Choices = new string[numChoices]; newChoice->m_ID = ID; if (newChoice->m_ScrollDisabled) newChoice->m_Border = SDL_CreateRGBSurface(SDL_SWSURFACE, newChoice->m_Width + 2, newChoice->m_Height + 2, 32, 0, 0, 0, 0); else newChoice->m_Border = SDL_CreateRGBSurface(SDL_SWSURFACE, newChoice->m_Width + 20, newChoice->m_Height + 2, 32, 0, 0, 0, 0); SDL_FillRect(newChoice->m_Border, 0, SDL_MapRGB(newChoice->m_Border->format, 0, 0, 0)); if (newChoice->m_ScrollDisabled) newChoice->m_Background = SDL_CreateRGBSurface(SDL_SWSURFACE, newChoice->m_Width, newChoice->m_Height, 32, 0, 0, 0, 0); else newChoice->m_Background = SDL_CreateRGBSurface(SDL_SWSURFACE, newChoice->m_Width - (18), newChoice->m_Height - 2, 32, 0, 0, 0, 0); SDL_FillRect(newChoice->m_Background, 0, SDL_MapRGB(newChoice->m_Background->format, 88, 163, 113)); newChoice->m_ElementBackground = SDL_CreateRGBSurface(SDL_SWSURFACE, newChoice->m_eWidth, newChoice->m_eHeight, 32, 0, 0, 0, 0); SDL_FillRect(newChoice->m_ElementBackground, 0, SDL_MapRGB(newChoice->m_ElementBackground->format, 88, 163, 113)); newChoice->m_ElementSelectedBackground = SDL_CreateRGBSurface(SDL_SWSURFACE, newChoice->m_eWidth, newChoice->m_eHeight, 32, 0, 0, 0, 0); SDL_FillRect(newChoice->m_ElementSelectedBackground, 0, SDL_MapRGB(newChoice->m_ElementSelectedBackground->format, 229, 227, 52)); if (newChoice->m_eWidth > 120) newChoice->m_HeaderBackground = SDL_CreateRGBSurface(SDL_SWSURFACE, newChoice->m_eWidth, 32, 32, 0, 0, 0, 0); else newChoice->m_HeaderBackground = SDL_CreateRGBSurface(SDL_SWSURFACE, 120, 32, 32, 0, 0, 0, 0); SDL_FillRect(newChoice->m_HeaderBackground, 0, SDL_MapRGB(newChoice->m_HeaderBackground->format, 229, 227, 52)); newChoice->m_XPos = ((g_Graphics.GetWidth() / 2) - (newChoice->m_Width / 2)); newChoice->m_YPos = ((g_Graphics.GetHeight() / 2) - (newChoice->m_Height / 2)); } if (m_UpOn == 0) m_UpOn = new ButtonSurface("UpOn"); if (m_UpOff == 0) m_UpOff = new ButtonSurface("UpOff"); m_CurrUp = m_UpOff; if (m_DownOn == 0) m_DownOn = new ButtonSurface("DownOn"); if (m_DownOff == 0) m_DownOff = new ButtonSurface("DownOff"); m_CurrDown = m_DownOff; if (!m_Parent) { m_Parent = newChoice; return; } cChoice* current = m_Parent; while (current->m_Next) current = current->m_Next; current->m_Next = newChoice; }
/* * changed this to take a filename so we can pass config files on the command line * default is config.xml */ sConfigData::sConfigData(const char *a_filename) : fonts() { DirPath dp = DirPath() << a_filename; // `J` moved to root directory DirPath dpold = DirPath() << "Resources" << "Data" << a_filename; string filename = dp.c_str(); string filenameold = dpold.c_str(); l.ss() << "Loading configuration variables from '" << filename << "'"; l.ssend(); /* * make sure we have something playable, * even if the file doesn't load */ set_defaults(); /* * open the file - moan most eloqently in its absence */ TiXmlDocument doc(filename); TiXmlDocument docold(filenameold); if (!doc.LoadFile()) { l.ss() << "Can't load " << filename << " from root directory." << endl << "Error: line " << doc.ErrorRow() << ", col " << doc.ErrorCol() << ": " << doc.ErrorDesc() << endl << "Attempting to load old file " << filenameold << "." << endl; l.ssend(); doc = docold; } if (!doc.LoadFile()) { l.ss() << "can't load " << filename << endl << "Error: line " << doc.ErrorRow() << ", col " << doc.ErrorCol() << ": " << doc.ErrorDesc(); l.ssend(); /* * a bit of narrative for the players: makes it easier to tell * if the config isn't being found */ l.ss() << "*** Game will run with default pricing factors.\n*** This may seem a little easy. To fix this\n*** get a config.xml file from pinkpetal.org\n*** or make one with W***e Master Editor"; l.ssend(); return; } /* * get the docuement root */ TiXmlElement *el, *root_el = doc.RootElement(); /* * loop over the elements attached to the root */ for (el = root_el->FirstChildElement(); el; el = el->NextSiblingElement()) { string tag = el->ValueStr(); // now, depending on the tag name... if (el->ValueStr() == "Folders") { get_folders_data(el); continue; } if (el->ValueStr() == "Resolution") { get_resolution_data(el); continue; } if (el->ValueStr() == "Initial") { get_initial_values(el); continue; } if (el->ValueStr() == "Income") { get_income_factors(el); continue; } if (el->ValueStr() == "Expenses") { get_expense_factors(el); continue; } if (el->ValueStr() == "Gambling") { get_gambling_factors(el); continue; } if (el->ValueStr() == "Prostitution") { get_pros_factors(el); continue; } if (el->ValueStr() == "Catacombs") { get_catacombs_data(el); continue; } if (el->ValueStr() == "SlaveMarket") { get_slave_market_data(el);continue; } if (el->ValueStr() == "Pregnancy") { get_preg_factors(el); continue; } if (el->ValueStr() == "Tax") { get_tax_factors(el); continue; } if (el->ValueStr() == "Gangs") { get_gang_factors(el); continue; } if (el->ValueStr() == "Items") { get_item_data(el); continue; } if (el->ValueStr() == "Fonts") { get_font_data(el); continue; } if (el->ValueStr() == "Debug") { get_debug_flags(el); continue; } l.ss() << "Warning: config.xml: tag: '" << tag << "' unexpected"; l.ssend(); } // check interface for colors DirPath dpi = DirPath() << "Resources" << "Interface" << resolution.resolution << "InterfaceColors.xml"; TiXmlDocument doci(dpi.c_str()); if (doci.LoadFile()) { string m_filename = dpi.c_str(); TiXmlElement *el, *root_el = doci.RootElement(); for (el = root_el->FirstChildElement(); el; el = el->NextSiblingElement()) { string tag = el->ValueStr(); if (tag == "Color") { XmlUtil xu(m_filename); string name; int r, g, b; xu.get_att(el, "Name", name); xu.get_att(el, "R", r); xu.get_att(el, "G", g); xu.get_att(el, "B", b); /* */if (name == "ItemRarity0") ColorConvert.RGBToSDLColor(items.rarity_color[0], r, g, b); else if (name == "ItemRarity1") ColorConvert.RGBToSDLColor(items.rarity_color[1], r, g, b); else if (name == "ItemRarity2") ColorConvert.RGBToSDLColor(items.rarity_color[2], r, g, b); else if (name == "ItemRarity3") ColorConvert.RGBToSDLColor(items.rarity_color[3], r, g, b); else if (name == "ItemRarity4") ColorConvert.RGBToSDLColor(items.rarity_color[4], r, g, b); else if (name == "ItemRarity5") ColorConvert.RGBToSDLColor(items.rarity_color[5], r, g, b); else if (name == "ItemRarity6") ColorConvert.RGBToSDLColor(items.rarity_color[6], r, g, b); else if (name == "ItemRarity7") ColorConvert.RGBToSDLColor(items.rarity_color[7], r, g, b); else if (name == "ItemRarity8") ColorConvert.RGBToSDLColor(items.rarity_color[8], r, g, b); } } } fonts.detailfontsize = 9; // default to 9 then check if it is set in girl_details_screen.xml DirPath dpt = DirPath() << "Resources" << "Interface" << resolution.resolution << "girl_details_screen.xml"; TiXmlDocument doct(dp.c_str()); if (doct.LoadFile()) { string m_filename = dpt.c_str(); TiXmlElement *el, *root_el = doct.RootElement(); for (el = root_el->FirstChildElement(); el; el = el->NextSiblingElement()) { string tag = el->ValueStr(); if (tag == "Text") { XmlUtil xu(m_filename); string name; int f = 9; xu.get_att(el, "Name", name); xu.get_att(el, "FontSize", f, true); if (name == "GirlDescription" && f > 0) { fonts.detailfontsize = f; break; } } } } }