本文整理汇总了C++中gui::Fixed::SetTransparency方法的典型用法代码示例。如果您正苦于以下问题:C++ Fixed::SetTransparency方法的具体用法?C++ Fixed::SetTransparency怎么用?C++ Fixed::SetTransparency使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gui::Fixed
的用法示例。
在下文中一共展示了Fixed::SetTransparency方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DialogMainLoop
void GameLoaderSaver::DialogMainLoop()
{
Gui::Fixed *background = new Gui::Fixed(float(Gui::Screen::GetWidth()), float(Gui::Screen::GetHeight()));
background->SetTransparency(false);
background->SetBgColor(0,0,0,1.0);
Gui::Fixed *outer = new Gui::Fixed(410, 410);
outer->SetTransparency(false);
background->Add(outer, 195, 45);
Gui::Fixed *inner = new Gui::Fixed(400, 400);
outer->Add(inner, 5, 5);
FileSelectorWidget *fileSelector = new FileSelectorWidget(m_type, m_title);
inner->Add(fileSelector, 0, 0);
fileSelector->onClickAction.connect(sigc::mem_fun(this, &GameLoaderSaver::OnClickLoad));
fileSelector->onClickCancel.connect(sigc::mem_fun(this, &GameLoaderSaver::OnClickBack));
Gui::Screen::AddBaseWidget(background, 0, 0);
background->ShowAll();
m_done = false;
while (!m_done)
Gui::MainLoopIteration();
Gui::Screen::RemoveBaseWidget(background);
delete background;
}
示例2: ShowBadError
void Screen::ShowBadError(const char *msg)
{
fprintf(stderr, "%s", msg);
baseContainer->HideChildren();
Gui::Fixed *f = new Gui::Fixed(6*GetWidth()/8, 6*GetHeight()/8);
Gui::Screen::AddBaseWidget(f, GetWidth()/8, GetHeight()/8);
f->SetTransparency(false);
f->SetBgColor(0.4,0,0,1.0);
f->Add(new Gui::Label(msg), 10, 10);
Gui::Button *okButton = new Gui::LabelButton(new Gui::Label("Ok"));
okButton->SetShortcut(SDLK_RETURN, KMOD_NONE);
f->Add(okButton, 10, 6*GetHeight()/8 - 32);
f->ShowAll();
f->Show();
do {
Gui::MainLoopIteration();
SDL_Delay(10);
} while (!okButton->IsPressed());
Gui::Screen::RemoveBaseWidget(f);
delete f;
baseContainer->ShowAll();
}
示例3: ShowBadError
void Screen::ShowBadError(const char *msg)
{
// to make things simple for ourselves, we want to hide all the existing widgets
// however, if we do it through baseContainer->HideChildren() then we lose track of
// which widgets should be shown again when the red-screen is cleared.
// So to avoid this problem we don't hide anything, we just temporarily swap to
// a different base container which is just used for this red-screen
Gui::Fixed *oldBaseContainer = Screen::baseContainer;
Screen::baseContainer = new Gui::Fixed();
Screen::baseContainer->SetSize(float(Screen::width), float(Screen::height));
Screen::baseContainer->Show();
Gui::Fixed *f = new Gui::Fixed(6*GetWidth()/8.0f, 6*GetHeight()/8.0f);
Gui::Screen::AddBaseWidget(f, GetWidth()/8, GetHeight()/8);
f->SetTransparency(false);
f->SetBgColor(0.4f,0,0,1.0f);
f->Add(new Gui::Label(msg, TextLayout::ColourMarkupNone), 10, 10);
Gui::Button *okButton = new Gui::LabelButton(new Gui::Label("Ok"));
okButton->SetShortcut(SDLK_RETURN, KMOD_NONE);
f->Add(okButton, 10.0f, 6*GetHeight()/8.0f - 32);
f->ShowAll();
f->Show();
do {
Gui::MainLoopIteration();
SDL_Delay(10);
} while (!okButton->IsPressed());
delete f; // Gui::Fixed does a horrible thing and calls Gui::Screen::RemoveBaseWidget(this) in its destructor
delete Screen::baseContainer;
Screen::baseContainer = oldBaseContainer;
}
示例4: Start
void Pi::Start()
{
WorldView *view = new WorldView();
Gui::Fixed *splash = new Gui::Fixed(Gui::Screen::GetWidth(), Gui::Screen::GetHeight());
Gui::Screen::AddBaseWidget(splash, 0, 0);
splash->SetTransparency(true);
const float w = Gui::Screen::GetWidth() / 2;
const float h = Gui::Screen::GetHeight() / 2;
const int OPTS = 5;
Gui::ToggleButton *opts[OPTS];
opts[0] = new Gui::ToggleButton(); opts[0]->SetShortcut(SDLK_1, KMOD_NONE);
opts[1] = new Gui::ToggleButton(); opts[1]->SetShortcut(SDLK_2, KMOD_NONE);
opts[2] = new Gui::ToggleButton(); opts[2]->SetShortcut(SDLK_3, KMOD_NONE);
opts[3] = new Gui::ToggleButton(); opts[3]->SetShortcut(SDLK_4, KMOD_NONE);
opts[4] = new Gui::ToggleButton(); opts[4]->SetShortcut(SDLK_5, KMOD_NONE);
splash->Add(opts[0], w, h-64);
splash->Add(new Gui::Label("New game starting on Earth"), w+32, h-64);
splash->Add(opts[1], w, h-32);
splash->Add(new Gui::Label("New game starting on Epsilon Eridani"), w+32, h-32);
splash->Add(opts[2], w, h);
splash->Add(new Gui::Label("New game starting on debug point"), w+32, h);
splash->Add(opts[3], w, h+32);
splash->Add(new Gui::Label("Load a saved game"), w+32, h+32);
splash->Add(opts[4], w, h+64);
splash->Add(new Gui::Label("Quit"), w+32, h+64);
splash->ShowAll();
int choice = 0;
Uint32 last_time = SDL_GetTicks();
float _time = 0;
do {
Pi::HandleEvents();
Render::PrepareFrame();
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
float fracH = 1.0 / Pi::GetScrAspect();
glFrustum(-1, 1, -fracH, fracH, 1.0f, 10000.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glClearColor(0,0,0,0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
SDL_ShowCursor(1);
SDL_WM_GrabInput(SDL_GRAB_OFF);
draw_intro(view, _time);
Render::PostProcess();
Gui::Draw();
Render::SwapBuffers();
Pi::frameTime = 0.001*(SDL_GetTicks() - last_time);
_time += Pi::frameTime;
last_time = SDL_GetTicks();
// poll ui instead of using callbacks :-J
for (int i=0; i<OPTS; i++) if (opts[i]->GetPressed()) choice = i+1;
} while (!choice);
splash->HideAll();
Gui::Screen::RemoveBaseWidget(splash);
delete splash;
delete view;
InitGame();
if (choice == 1) {
/* Earth start point */
SBodyPath path(0,0,0);
Space::DoHyperspaceTo(&path);
//Frame *pframe = *(++(++(Space::rootFrame->m_children.begin())));
//player->SetFrame(pframe);
// XXX there isn't a sensible way to find stations for a planet.
SpaceStation *station = 0;
for (Space::bodiesIter_t i = Space::bodies.begin(); i!=Space::bodies.end(); i++) {
if ((*i)->IsType(Object::SPACESTATION)) { station = (SpaceStation*)*i; break; }
}
assert(station);
player->SetPosition(vector3d(0,0,0));
player->SetFrame(station->GetFrame());
player->SetDockedWith(station, 0);
MainLoop();
} else if (choice == 2) {
/* Epsilon Eridani start point */
SBodyPath path(1,0,2);
Space::DoHyperspaceTo(&path);
// XXX there isn't a sensible way to find stations for a planet.
SpaceStation *station = 0;
for (Space::bodiesIter_t i = Space::bodies.begin(); i!=Space::bodies.end(); i++) {
if ((*i)->IsType(Object::SPACESTATION)) {
station = (SpaceStation*)*i;
if (!station->IsGroundStation()) break;
}
}
assert(station);
player->SetPosition(vector3d(0,0,0));
player->SetFrame(station->GetFrame());
//.........这里部分代码省略.........
示例5: ShowAll
void CommodityTradeWidget::ShowAll()
{
DeleteAllChildren();
m_stockLabels.clear();
m_cargoLabels.clear();
SetTransparency(true);
Gui::VScrollBar *scroll = new Gui::VScrollBar();
Gui::VScrollPortal *portal = new Gui::VScrollPortal(450);
scroll->SetAdjustment(&portal->vscrollAdjust);
//int GetStock(Equip::Type t) const { return m_equipmentStock[t]; }
int NUM_ITEMS = 0;
const float YSEP = floor(Gui::Screen::GetFontHeight() * 2.5f);
for (int i=Equip::FIRST_COMMODITY; i<=Equip::LAST_COMMODITY; i++) {
assert(Equip::types[i].slot == Equip::SLOT_CARGO);
if (m_seller->DoesSell(Equip::Type(i))) {
NUM_ITEMS++;
}
}
Gui::Fixed *innerbox = new Gui::Fixed(450, NUM_ITEMS*YSEP);
innerbox->SetTransparency(true);
const float iconOffset = 8.0f;
for (int i=Equip::FIRST_COMMODITY, num=0; i<=Equip::LAST_COMMODITY; i++) {
assert(Equip::types[i].slot == Equip::SLOT_CARGO);
if (!m_seller->DoesSell(Equip::Type(i))) continue;
int stock = m_seller->GetStock(static_cast<Equip::Type>(i));
std::map<Equip::Type,std::string>::iterator icon_iter = s_iconMap.find(Equip::Type(i));
if (icon_iter != s_iconMap.end()) {
Gui::Image *icon = new Gui::Image(("icons/goods/" + (*icon_iter).second + ".png").c_str());
// this forces the on-screen rendering to fit within (rescale) to these dimensions
icon->SetRenderDimensions(38.0f, 32.0f);
innerbox->Add(icon, 0, num*YSEP);
}
Gui::Label *l = new Gui::Label(Equip::types[i].name);
if (Equip::types[i].description)
l->SetToolTip(Equip::types[i].description);
innerbox->Add(l,42,num*YSEP+iconOffset);
Gui::RepeaterButton *b = new Gui::RepeaterButton(RBUTTON_DELAY, RBUTTON_REPEAT);
sigc::slot<void> func = sigc::bind(sigc::mem_fun(this, &CommodityTradeWidget::OnClickBuy), i);
b->onClick.connect(sigc::bind(sigc::mem_fun(this, &CommodityTradeWidget::ManageRButton), b, func));
innerbox->Add(b, 380, num*YSEP+iconOffset);
b = new Gui::RepeaterButton(RBUTTON_DELAY, RBUTTON_REPEAT);
func = sigc::bind(sigc::mem_fun(this, &CommodityTradeWidget::OnClickSell), i);
b->onClick.connect(sigc::bind(sigc::mem_fun(this, &CommodityTradeWidget::ManageRButton), b, func));
innerbox->Add(b, 415, num*YSEP+iconOffset);
char buf[128];
innerbox->Add(new Gui::Label(
format_money(m_seller->GetPrice(static_cast<Equip::Type>(i)))
), 200, num*YSEP+iconOffset);
snprintf(buf, sizeof(buf), "%dt", stock*Equip::types[i].mass);
Gui::Label *stocklabel = new Gui::Label(buf);
m_stockLabels[i] = stocklabel;
innerbox->Add(stocklabel, 275, num*YSEP+iconOffset);
snprintf(buf, sizeof(buf), "%dt", Pi::player->m_equipment.Count(Equip::SLOT_CARGO, static_cast<Equip::Type>(i))*Equip::types[i].mass);
Gui::Label *cargolabel = new Gui::Label(buf);
m_cargoLabels[i] = cargolabel;
innerbox->Add(cargolabel, 325, num*YSEP+iconOffset);
num++;
}
innerbox->ShowAll();
portal->Add(innerbox);
portal->ShowAll();
Gui::Fixed *heading = new Gui::Fixed(470, Gui::Screen::GetFontHeight());
const Color &col = Gui::Theme::Colors::tableHeading;
heading->Add((new Gui::Label(Lang::ITEM))->Color(col), 0, 0);
heading->Add((new Gui::Label(Lang::PRICE))->Color(col), 200, 0);
heading->Add((new Gui::Label(Lang::BUY))->Color(col), 380, 0);
heading->Add((new Gui::Label(Lang::SELL))->Color(col), 415, 0);
heading->Add((new Gui::Label(Lang::STOCK))->Color(col), 275, 0);
heading->Add((new Gui::Label(Lang::CARGO))->Color(col), 325, 0);
PackEnd(heading);
Gui::HBox *body = new Gui::HBox();
body->PackEnd(portal);
body->PackEnd(scroll);
PackEnd(body);
SetSpacing(YSEP-Gui::Screen::GetFontHeight());
Gui::VBox::ShowAll();
}
示例6: FaceForm
StationShipEquipmentForm::StationShipEquipmentForm(FormController *controller) : FaceForm(controller)
{
m_station = Pi::player->GetDockedWith();
SetTitle(stringf(Lang::SOMEWHERE_SHIP_EQUIPMENT, formatarg("station", m_station->GetLabel())));
Gui::VScrollBar *scroll = new Gui::VScrollBar();
Gui::VScrollPortal *portal = new Gui::VScrollPortal(450);
scroll->SetAdjustment(&portal->vscrollAdjust);
int NUM_ITEMS = 0;
const float YSEP = floor(Gui::Screen::GetFontHeight() * 1.5f);
for (int i=Equip::FIRST_SHIPEQUIP; i<=Equip::LAST_SHIPEQUIP; i++) {
if (m_station->GetStock(static_cast<Equip::Type>(i)))
NUM_ITEMS++;
}
Gui::VBox *outerbox = new Gui::VBox();
Gui::Fixed *innerbox = new Gui::Fixed(450, NUM_ITEMS*YSEP);
innerbox->SetTransparency(true);
for (int i=Equip::FIRST_SHIPEQUIP, num=0; i<=Equip::LAST_SHIPEQUIP; i++) {
Equip::Type type = static_cast<Equip::Type>(i);
int stock = m_station->GetStock(type);
if (!stock) continue;
Gui::Label *l = new Gui::Label(Equip::types[i].name);
if (Equip::types[i].description) {
l->SetToolTip(Equip::types[i].description);
}
innerbox->Add(l,0,num*YSEP);
innerbox->Add(new Gui::Label(format_money(m_station->GetPrice(type))), 200, num*YSEP);
innerbox->Add(new Gui::Label(format_money(REMOVAL_VALUE_PERCENT * m_station->GetPrice(type) / 100)),
275, num*YSEP);
innerbox->Add(new Gui::Label(stringf(Lang::NUMBER_TONNES, formatarg("mass", Equip::types[i].mass))), 360, num*YSEP);
ButtonPair pair;
pair.type = type;
pair.add = new Gui::SolidButton();
pair.add->onClick.connect(sigc::bind(sigc::mem_fun(this, &StationShipEquipmentForm::FitItem), type));
innerbox->Add(pair.add, 400, num*YSEP);
pair.remove = new Gui::SolidButton();
pair.remove->onClick.connect(sigc::bind(sigc::mem_fun(this, &StationShipEquipmentForm::RemoveItem), type));
innerbox->Add(pair.remove, 420, num*YSEP);
m_buttons.push_back(pair);
num++;
}
portal->Add(innerbox);
Gui::Fixed *heading = new Gui::Fixed(470, Gui::Screen::GetFontHeight());
const float *col = Gui::Theme::Colors::tableHeading;
heading->Add((new Gui::Label(Lang::ITEM))->Color(col), 0, 0);
heading->Add((new Gui::Label(Lang::PRICE_TO_FIT))->Color(col), 200, 0);
heading->Add((new Gui::Label(Lang::PRICE_TO_REMOVE))->Color(col), 275, 0);
heading->Add((new Gui::Label(Lang::WT))->Color(col), 360, 0);
heading->Add((new Gui::Label(Lang::FIT))->Color(col), 400, 0);
heading->Add((new Gui::Label(Lang::REMOVE))->Color(col), 420, 0);
outerbox->PackEnd(heading);
Gui::HBox *body = new Gui::HBox();
body->PackEnd(portal);
body->PackEnd(scroll);
outerbox->PackEnd(body);
outerbox->SetSpacing(YSEP-Gui::Screen::GetFontHeight());
Add(outerbox, 0, 0);
}