Beispiel #1
0
BBGraphics *Win32DDCanvas::graphics(){

	if( _graphics ) return _graphics;

	_graphics=new Win32DDGraphics( width(),height(),Win32DDGraphics::TYPE_VIDMEM );

	setGraphics( _graphics );

	return _graphics;
}
Beispiel #2
0
Gui::Gui(Graphics *graphics):
    mCustomCursor(false),
    mMouseCursors(NULL),
    mMouseCursorAlpha(1.0f),
    mMouseInactivityTimer(0),
    mCursorType(CURSOR_POINTER)
{
    logger->log("Initializing GUI...");
    // Set graphics
    setGraphics(graphics);

    // Set image loader
    static ImageLoader imageLoader;
    gcn::Image::setImageLoader(&imageLoader);

    // Set input
    guiInput = new SDLInput;
    setInput(guiInput);

    // Set focus handler
    delete mFocusHandler;
    mFocusHandler = new FocusHandler;

    // Initialize top GUI widget
    WindowContainer *guiTop = new WindowContainer;
    guiTop->setFocusable(true);
    guiTop->setSize(graphics->getWidth(), graphics->getHeight());
    guiTop->setOpaque(false);
    Window::setWindowContainer(guiTop);
    setTop(guiTop);

    ResourceManager *resman = ResourceManager::getInstance();

    // Set global font
    const int fontSize = config.getValue("fontSize", 11);
    std::string fontFile = branding.getValue("font", "fonts/dejavusans.ttf");
    std::string path = resman->getPath(fontFile);

    try
    {
        mGuiFont = new TrueTypeFont(path, fontSize);
        mInfoParticleFont = new TrueTypeFont(path, fontSize, TTF_STYLE_BOLD);
    }
    catch (gcn::Exception e)
    {
        logger->error(std::string("Unable to load '") + fontFile +
                      std::string("': ") + e.getMessage());
    }

    // Set bold font
    fontFile = branding.getValue("boldFont", "fonts/dejavusans-bold.ttf");
    path = resman->getPath(fontFile);
    try
    {
        boldFont = new TrueTypeFont(path, fontSize);
    }
    catch (gcn::Exception e)
    {
        logger->error(std::string("Unable to load '") + fontFile +
                      std::string("': ") + e.getMessage());
    }

    // Set mono font
    fontFile = branding.getValue("monoFont", "fonts/dejavusans-mono.ttf");
    path = resman->getPath(fontFile);
    try
    {
        monoFont = new TrueTypeFont(path, fontSize);
    }
    catch (gcn::Exception e)
    {
        logger->error(std::string("Unable to load '") + fontFile +
                      std::string("': ") + e.getMessage());
    }

    gcn::Widget::setGlobalFont(mGuiFont);

    // Initialize mouse cursor and listen for changes to the option
    setUseCustomCursor(config.getBoolValue("customcursor"));
    mConfigListener = new GuiConfigListener(this);
    mConfigListener->listen(Event::ConfigChannel);
}
Beispiel #3
0
void Gui::postInit(Graphics *const graphics)
{
    logger->log1("Initializing GUI...");
    // Set graphics
    setGraphics(graphics);

    // Set input
    guiInput = new SDLInput;
    setInput(guiInput);

    // Set focus handler
    delete mFocusHandler;
    mFocusHandler = new FocusHandler;

    // Initialize top GUI widget
    WindowContainer *const guiTop = new WindowContainer(nullptr);
    guiTop->setFocusable(true);
    guiTop->setSize(graphics->mWidth, graphics->mHeight);
    guiTop->setOpaque(false);
    Window::setWindowContainer(guiTop);
    setTop(guiTop);

    const StringVect langs = getLang();
    const bool isJapan = (!langs.empty() && langs[0].size() > 3
        && langs[0].substr(0, 3) == "ja_");
    const bool isChinese = (!langs.empty() && langs[0].size() > 3
        && langs[0].substr(0, 3) == "zh_");

    // Set global font
    const int fontSize = config.getIntValue("fontSize");
    std::string fontFile = config.getValue("font", "");
    if (isJapan)
    {
        fontFile = config.getValue("japanFont", "");
        if (fontFile.empty())
            fontFile = branding.getStringValue("japanFont");
    }
    else if (isChinese)
    {
        fontFile = config.getValue("chinaFont", "");
        if (fontFile.empty())
            fontFile = branding.getStringValue("chinaFont");
    }
    if (fontFile.empty())
        fontFile = branding.getStringValue("font");

    mGuiFont = new Font(fontFile, fontSize);

    // Set particle font
    fontFile = config.getValue("particleFont", "");
    if (isJapan)
    {
        fontFile = config.getValue("japanFont", "");
        if (fontFile.empty())
            fontFile = branding.getStringValue("japanFont");
    }
    else if (isChinese)
    {
        fontFile = config.getValue("chinaFont", "");
        if (fontFile.empty())
            fontFile = branding.getStringValue("chinaFont");
    }
    if (fontFile.empty())
        fontFile = branding.getStringValue("particleFont");

    mInfoParticleFont = new Font(fontFile, fontSize, TTF_STYLE_BOLD);

    // Set bold font
    fontFile = config.getValue("boldFont", "");
    if (fontFile.empty())
        fontFile = branding.getStringValue("boldFont");

    boldFont = new Font(fontFile, fontSize);

    // Set help font
    fontFile = config.getValue("helpFont", "");
    if (fontFile.empty())
        fontFile = branding.getStringValue("helpFont");

    mHelpFont = new Font(fontFile, fontSize);

    // Set secure font
    fontFile = config.getValue("secureFont", "");
    if (fontFile.empty())
        fontFile = branding.getStringValue("secureFont");

    mSecureFont = new Font(fontFile, fontSize);

    // Set npc font
    const int npcFontSize = config.getIntValue("npcfontSize");
    fontFile = config.getValue("npcFont", "");
    if (isJapan)
    {
        fontFile = config.getValue("japanFont", "");
        if (fontFile.empty())
            fontFile = branding.getStringValue("japanFont");
    }
    else if (isChinese)
    {
        fontFile = config.getValue("chinaFont", "");
        if (fontFile.empty())
            fontFile = branding.getStringValue("chinaFont");
    }
    if (fontFile.empty())
        fontFile = branding.getStringValue("npcFont");

    mNpcFont = new Font(fontFile, npcFontSize);

    Widget::setGlobalFont(mGuiFont);

    // Initialize mouse cursor and listen for changes to the option
    setUseCustomCursor(config.getBoolValue("customcursor"));
    setDoubleClick(config.getBoolValue("doubleClick"));
    config.addListener("customcursor", mConfigListener);
    config.addListener("doubleClick", mConfigListener);
}
Beispiel #4
0
int main(void){
	int i = 0;
	//Score set
	score = 0;
	PLL_Init();
	//Sound init
	DAC_Init();
	Timer0A_Init(Sound_Update, 1000000/11025);
//	Timer0B_Init(updateXAxis, 1000000/11025);
//	Timer1B_Init(updateYAxis, 1000000/11025);
	//Input
	ADC_Init();
	portD_Init();
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);
												GPIOPinTypeGPIOInput(GPIO_PORTG_BASE,
												(GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7));
												GPIOPinTypeGPIOOutput(GPIO_PORTG_BASE, GPIO_PIN_2);
												GPIOPadConfigSet(GPIO_PORTG_BASE,
												(GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7),
												GPIO_STRENGTH_2MA,
												GPIO_PIN_TYPE_STD_WPU);
	SysTick_Init(50000000/400);
	Output_Init();
	Output_Color(15);
	SysTick_IntEnable();
	EnableInterrupts();
	//Set flags
	gFlags = 0;
	HWREGBITW(&gFlags, TITLE_SCREEN) = True;	
	//Math rand set seed
	while(HWREGBITW(&gFlags, SELECT_DOWN) == 0 &&
				((GPIO_PORTG_DATA_R & 0x80) != 0)) { }
	while(HWREGBITW(&gFlags, SELECT_DOWN) == 1 ||
				((GPIO_PORTG_DATA_R & 0x80) == 0)) { }
	setSeed(NVIC_ST_CURRENT_R);
	//Game set
	setGraphics(1);//the lm3s can't handle more than 2 rocks at graphics level 3.
	gameInit();
	gameSet(0);
	while(1) {
		//Only draw to buffer when it has been output to the screen
		if(HWREGBITW(&gFlags, FRAME_BUFFER_READY) == False) {
			/*if(gameLevel == -2) {
				drawString(myMsgs[1], makePoint(50, 40));
				while ((GPIO_PORTG_DATA_R & 0x80) != 0 &&
							 HWREGBITW(&gFlags, SELECT_DOWN) == False) { }
				while ((GPIO_PORTG_DATA_R & 0x80) == 0 &&
							 HWREGBITW(&gFlags, SELECT_DOWN) == True) { }
				//Reset game
			*/
			//Check for level completion, aka all rocks and enemies are 
			//TODO: enemies
			if(HWREGBITW(&gFlags, LEVEL_COMPLETE) == True) { gameSet(++gameLevel); }
			//Redraw the screen from scratch.
			clearBuffer();
			//Draw the player.
			if(gPlayer.status == ALIVE) {
				drawPlayer(makePoint((int)gPlayer.x, (int)gPlayer.y),
									 gPlayer.angle, gPlayer.exhaustOn);
			}
			for(i = 0; i < MAX_ROCKS; i++) {
				if(gRocks[i].status == ALIVE) {
					drawRock(makePoint(gRocks[i].x, gRocks[i].y),
									 gRocks[i].rockType, gRocks[i].rockSize);
				}
			}
			//Draw allied bullets.
			for(i = 0; i < MAX_PLAYER_BULLETS; i++) {
				if(gPlayerBullets[i].status == ALIVE) {
					drawBullet(makePoint(gPlayerBullets[i].x, gPlayerBullets[i].y));
				}
			}
			//Draw enemy bullets.
			for(i = 0; i < MAX_ENEMY_BULLETS; i++) {
				if(gEnemyBullets[i].status == ALIVE) {
					drawBullet(makePoint(gEnemyBullets[i].x, gEnemyBullets[i].y));
				}
			}
			//Draw explosions.
			for(i = 0; i < MAX_EXPLOSIONS; i++) {
				if(gExplosions[i].status == ALIVE) {
					drawExplosion(gExplosions[i].pos, gExplosions[i].current);
				}
			}
			
			//
			drawNumber(score, makePoint(2,2));
			drawNumber(gameLevel, makePoint(128/2-6,2));
			
			if(HWREGBITW(&gFlags, GAME_OVER) == True) {
				drawString("GAME OVER", makePoint(40, 38));
				if((GPIO_PORTG_DATA_R & 0x80)) {
					//reset game
				}
				gameUpdate();
			} else if(HWREGBITW(&gFlags, TITLE_SCREEN) == True) {
				drawString("ASTEROIDS", makePoint(40, 38));
				gameLevel = 0;
			}
			updateXAxis();
			gameUpdate();
			HWREGBITW(&gFlags, FRAME_BUFFER_READY) = True;
		}
	}
}
Beispiel #5
0
GraphicButton::GraphicButton(ImagePtr normal, ImagePtr pressed)
{
    setGraphics(normal, pressed);
    m_pressed = false;
}