예제 #1
0
void DemoState::createRGBAWindow() {
	detachChild("rgbaWindow");

	windowRGBA = new Window("rgbaWindow", Vector2(), Vector2(270, 200), "images/WINDOW.tga");
	windowRGBA->attachChild(new Label("RGBALabel", "RGBA Colour", 10, ColourRGBA(ColourRGBA::WHITE), Vector2(10, 90)));

	rSlider = new Slider("rSlider", Vector2(20, 125), 230, HORIZONTAL);
	rSlider->setColour(ColourRGBA::RED);

	gSlider = new Slider("gSlider", Vector2(20, 90), 230, HORIZONTAL);
	gSlider->setColour(ColourRGBA::GREEN);

	bSlider = new Slider("bSlider", Vector2(20, 55), 230, HORIZONTAL);
	bSlider->setColour(ColourRGBA::BLUE);

	aSlider = new Slider("aSlider", Vector2(20, 20), 230, HORIZONTAL);
	aSlider->setColour(ColourRGBA(1, 1, 1, 0.5f));

	windowRGBA->attachChild(rSlider);
	windowRGBA->attachChild(gSlider);
	windowRGBA->attachChild(bSlider);
	windowRGBA->attachChild(aSlider);

	attachChild(windowRGBA);
}
예제 #2
0
void DemoState::valueUpdate(Slider& slider, int index) {
	if (slider == "rSlider" || slider == "gSlider"
	 || slider == "bSlider" || slider == "aSlider") {
		float r = (rSlider->getSelectedIndex() != 0 ? rSlider->getSelectedIndex() / 100.0f : 0),
			  g = (gSlider->getSelectedIndex() != 0 ? gSlider->getSelectedIndex() / 100.0f : 0),
			  b = (bSlider->getSelectedIndex() != 0 ? bSlider->getSelectedIndex() / 100.0f : 0),
			  a = (aSlider->getSelectedIndex() != 0 ? aSlider->getSelectedIndex() / 100.0f : 0);

		image->setColour(ColourRGBA(r, g, b, a));
	}
	else if (slider == "effects_speedSlider") {
		effectSpeed = index != 0 ? (float) index / 25 : 0;

		for (int i = GENERIC; i != TRIG_PRESSED; i++) {
			EffectTrigger trigger = static_cast<EffectTrigger>(i);

			if (image->getEffect(trigger) != nullptr) {
				image->getEffect(trigger)->setSpeed(effectSpeed);
			}
		}
	}
	else if (slider == "animSlider") {
		doomGuy->setAnimation(5 - index);

		if (index == 5) {
			slider.setColour(ColourRGBA::WHITE);
		}
		else {
			slider.setColour(ColourRGBA(0.2f * index, 0.0f, 0.0f, 1.0f));
		}
	}
	else if (slider == "animSpeed") {
		doomGuy->setDelay(index * 10);
	}
}
예제 #3
0
void ComboBox::addOption(const char* option) {
	Button* optionButton = createButton(option, optionCount);
			optionButton->addEffect(TRIG_HOVER, new ChangeColour(ColourRGBA(ColourRGBA::BLUE)));
			optionButton->setHoverForegroundColour(ColourRGBA(ColourRGBA::WHITE));

	elements[optionCount--] = new ComboElement(option, optionButton);
	p_buttonContainer->attachChild(optionButton);
}
예제 #4
0
Chatbox::Chatbox(const std::string& id, Vector2& position, float width) : GUIImage(id, "demo/images/chatbox/CHAT_BACK.tga") {
	setLocalTranslation(position);
	resize(width, 200);
	setDraggable(true);

	p_messageArea = new ScrollPane(id + "_scroll", Vector2(10, 38), Vector2(width - 20, 190));
	p_messageArea->setBackground("demo/images/chatbox/CHAT_FORE.tga");

	p_inputField = new TextField(id + "_input", Vector2(10, 10), width - 20);
	p_inputField->setCharacterLimit(32);
	p_inputField->setBackground("demo/images/chatbox/CHAT_FIELD.tga");
	p_inputField->setForegroundColour(ColourRGBA(ColourRGBA::WHITE));

	setPassFocusElement(p_messageArea);

	for (int i = 0; i != bufferSize; i++) {
		entryLabels.push_back(new Label("", "", 9, Vector2(4, (i + 1) * 10))); // We don't care about their IDs
		p_messageArea->attachChild(entryLabels[i]);
	}

	p_messageArea->floor();

	attachChild(p_messageArea);
	attachChild(p_inputField);
}
예제 #5
0
Button* ComboBox::createButton(const char* option, int optionCount) {
	Label* label = new Label("button_label_" + std::string(option), (char*) option, 10, ColourRGBA(), Vector2(4, 18));
	label->setShadowed(false);

	Button* optionButton = new Button("option_" + std::string(option), Vector2(0, (float) optionCount * 18), Vector2(width, 18));
	optionButton->setLabel(label);
	optionButton->setColour(ColourRGBA::WHITE);
	optionButton->setOnPress(press);
	return optionButton;
}
예제 #6
0
    void QuitConfirmMenu::Draw()
    {
        DrawTexturedRect(BACKGROUND, 0.0f, 0.0f, APP.GetScreenWidth(), APP.GetScreenHeight());

        DrawRect(ColourRGBA(0.0f, 0.0f, 0.0f, 0.5f), 0.0f, TITLE_STARTY - ITEM_SPACING,
            APP.GetScreenWidth(), APP.GetScreenHeight() - TITLE_STARTY + ITEM_SPACING);

        FONTS.Print(FONT, m_titleOrigin.GetX(), m_titleOrigin.GetY(), TITLE_HEIGHT, ColourRGBA::White(), Font::ALIGN_CENTER, "RSI Already?");

        // Draw the menu items
        MenuScreen::Draw();
    }
예제 #7
0
void DemoState::createEffectsWindow() {
	detachChild("effectsWindow"); // the pointer, p_effectsWindow, will be invalid if the window has been detached

	p_effectsWindow = new Window("effectsWindow", Vector2(), Vector2(432, 306), "images/WINDOW.tga");
	p_effectsWindow->setResizable(true);

	p_effectsWindow->attachChild(new Label("effectsWindow_TitleLabel", "Effects", 14, Vector2(15, 140)));
	p_effectsWindow->attachChild(new Label("effectsWindow_SubtitleLabel", "Some effects to play with.", 9, Vector2(15, 125)));

	Button* resetButton = new Button("resetEffects", Vector2(160, 25), Vector2(), "Reset");
	resetButton->assignImages("images/BUTTON.tga", "images/BUTTON_HOVER.tga", "images/BUTTON_PRESSED.tga");
	resetButton->getLabel()->translate(15, 0);

	p_effectsWindow->attachChild(resetButton);

	// Speed slider
	Slider* speedSlider = new Slider("effects_speedSlider", Vector2(140, 70), 230, HORIZONTAL);
	speedSlider->setIndex(50); // Defaults 1.0f
	speedSlider->attachChild(new Label("effects_speedSliderLabel", "Speed:", 10, ColourRGBA(ColourRGBA::WHITE), Vector2(-38, 12)));
	p_effectsWindow->attachChild(speedSlider);

	// "On hover off" effect
	onHoverOffEffect = createEffectsComboBox("setOnHoverOffEffect", Vector2(140, 115));
	onHoverOffEffect->attachChild(new Label("onHoverOffLabel", "On leave:", 10, ColourRGBA(ColourRGBA::WHITE), Vector2(-52, 10)));
	p_effectsWindow->attachChild(onHoverOffEffect);

	// "On hover" effect
	onHoverEffect = createEffectsComboBox("setOnHoverEffect", Vector2(140, 155));
	onHoverEffect->attachChild(new Label("onHoverLabel", "On hover:", 10, ColourRGBA(ColourRGBA::WHITE), Vector2(-55, 10)));
	p_effectsWindow->attachChild(onHoverEffect);

	// "General" effect
	generalEffect = createEffectsComboBox("setGeneralEffect", Vector2(140, 195));
	generalEffect->attachChild(new Label("generalLabel", "General:", 10, ColourRGBA(ColourRGBA::WHITE), Vector2(-50, 10)));
	p_effectsWindow->attachChild(generalEffect);
	
	effectSpeed = 2.0f;
	attachChild(p_effectsWindow);
}
예제 #8
0
void DemoState::createPlainWindow() {
	detachChild("plainWindow");

	plainWindow = new Window("plainWindow", Vector2(100, 100), Vector2(300, 200), ColourRGBA(ColourRGBA::CYAN));
	plainWindow->setDraggable(true);
	plainWindow->setResizable(true);
	plainWindow->setGradiant(TO_BOTTOM, 4.0f);

	ComboBox* gradiants = new ComboBox("gradiantCombo", Vector2(120, 80), 120);
	gradiants->setOptions(5, "To bottom", "To top", "To left", "To right", "None");
	gradiants->attachChild(new Label("gradLabel", "Gradiant:", 10, Vector2(-55, 10)));
	plainWindow->attachChild(gradiants);
	attachChild(plainWindow);
}
예제 #9
0
    void MainMenu::Draw()
    {
        DrawTexturedRect(BACKGROUND, 0.0f, 0.0f, APP.GetScreenWidth(),
                        APP.GetScreenHeight());

        DrawRect(ColourRGBA(0.0f, 0.0f, 0.0f, 0.5f), 0.0f, ITEM_STARTY - ITEM_SPACING,
            APP.GetScreenWidth(), APP.GetScreenHeight() - ITEM_STARTY + ITEM_SPACING);

        // Draw the version number
        FONTS.Print(VERSION_FONT, APP.GetScreenWidth(), APP.GetScreenHeight() - 12.0f, 12.0f, ColourRGBA::White(), Font::ALIGN_RIGHT,
                    (boost::format("v%1%.%2% - %3%") % App::MAJOR_VERSION % App::MINOR_VERSION % __DATE__).str());

        // Draw the menu items
        MenuScreen::Draw();
    }
예제 #10
0
    void ExtraLife::Draw3D()
    {
        ColourRGBA sphereColour(POWERUP_SPHERE_COLOUR);
        const float blinkTime = (GAME.GetTime() - m_spawnTime) - (POWERUP_LIFETIME - POWERUP_BLINK_TIME);
        if (blinkTime > 0.0f) {
            sphereColour[ColourRGBA::COLOUR_ALPHA] = POWERUP_SPHERE_COLOUR.GetAlpha() *
                abs(cosf((blinkTime / POWERUP_BLINK_TIME) * static_cast<float>(M_PI) * POWERUP_BLINK_SPEED));
        }

        glPushMatrix();
            glTranslatef(m_origin[0], m_origin[1], m_origin[2]);
            glScalef(20.0f, 20.0f, 20.0f);
            DrawSphere(ColourRGBA(sphereColour));
        glPopMatrix();
    }
예제 #11
0
void DemoState::createImage(const std::string& imagePath) {
	detachChild("demoImage");

	image = new GUIImage("demoImage", imagePath);
	image->setLocalTranslation(Vector2(-503, -363));
	image->setDraggable(true);

	if (hasChild("rgbaWindow")) {
		float r = (rSlider->getSelectedIndex() != 0 ? rSlider->getSelectedIndex() / 100.0f : 0),
			  g = (gSlider->getSelectedIndex() != 0 ? gSlider->getSelectedIndex() / 100.0f : 0),
			  b = (bSlider->getSelectedIndex() != 0 ? bSlider->getSelectedIndex() / 100.0f : 0),
			  a = (aSlider->getSelectedIndex() != 0 ? aSlider->getSelectedIndex() / 100.0f : 0);

		image->setColour(ColourRGBA(r, g, b, a));
	}
	attachChild(image);
}
예제 #12
0
OSDInstance::OSDInstance() :
		osdText("Gathering data...") {
	const ConfigurationManager &configurationManager =
			GLXOSD::instance()->getConfigurationManager();

	std::string fontName = configurationManager.getProperty<std::string>(
			"font_name");
	int fontSize = configurationManager.getProperty<int>("font_size_int");
	int fontColourR = configurationManager.getProperty<int>(
			"font_colour_r_int");
	int fontColourG = configurationManager.getProperty<int>(
			"font_colour_g_int");
	int fontColourB = configurationManager.getProperty<int>(
			"font_colour_b_int");
	int fontColourA = configurationManager.getProperty<int>(
			"font_colour_a_int");
	int fontOutlineColourR = configurationManager.getProperty<int>(
			"font_outline_colour_r_int");
	int fontOutlineColourG = configurationManager.getProperty<int>(
			"font_outline_colour_g_int");
	int fontOutlineColourB = configurationManager.getProperty<int>(
			"font_outline_colour_b_int");
	int fontOutlineColourA = configurationManager.getProperty<int>(
			"font_outline_colour_a_int");

	float outlineWidth =
			configurationManager.getProperty<bool>("show_text_outline_bool") ?
					configurationManager.getProperty<float>(
							"font_outline_width_float") :
					0;

	int horizontalDPI = configurationManager.getProperty<int>(
			"font_dpi_horizontal_int");
	int verticalDPI = configurationManager.getProperty<int>(
			"font_dpi_vertical_int");

	int textPositionX = configurationManager.getProperty<int>("text_pos_x_int");
	int textPositionY = configurationManager.getProperty<int>("text_pos_y_int");
	float textSpacingY = configurationManager.getProperty<float>(
			"text_spacing_y_float");
	float textSpacingX = configurationManager.getProperty<float>(
			"text_spacing_x_float");

	fpsFormat = configurationManager.getProperty<boost::format>("fps_format");

	frameLoggingMessage = configurationManager.getProperty<std::string>(
			"frame_logging_message_string");
	frameLoggingDumpInProgressMessage = configurationManager.getProperty<std::string>(
			"frame_logging_dump_in_progress_message_string");

	renderer = new FontRenderer(fontName, fontSize, horizontalDPI, verticalDPI,
			outlineWidth);
	renderer->setFontColour(
			ColourRGBA(fontColourR, fontColourG, fontColourB, fontColourA));
	renderer->setFontOutlineColour(
			ColourRGBA(fontOutlineColourR, fontOutlineColourG,
					fontOutlineColourB, fontOutlineColourA));

	renderer->setTextPositionX(textPositionX);
	renderer->setTextPositionY(textPositionY);
	renderer->setTextSpacingX(textSpacingX);
	renderer->setTextSpacingY(textSpacingY);

	currentFrameCount = 0;
	framesPerSecond = 0;
//Set the time for the first time.
	previousTime = getMonotonicTimeNanoseconds() / 1000000ULL;
}