コード例 #1
0
ファイル: Environment.cpp プロジェクト: boourns/opendash
void Environment::update()
{
  int fMenuHeight = 0;
  int fMenuEntryHeight = 0;
  int fTarget = 0;
  int i,j;
  Element *t;

  // fix out of range mMenuSelected values.
  if (mMenuSelected < 0) {
    mMenuSelected = 0;
    renderMenu();
  }

  if (mMenuSelected >= mMenu->getChildren()->getLength()) {
    mMenuSelected = mMenu->getChildren()->getLength()-1;
    renderMenu();
  }

  t = mElements->getElementByContent(CONTENT_MENU, mMenu->getSkinID());
  if (t) {
    fMenuHeight = t->getDimensions().h;
  }
  t = mElements->getElementByContent(CONTENT_MENUENTRY_BG, mMenu->getSkinID());
  if (t) {
    fMenuEntryHeight = t->getDimensions().h;
  }
}
コード例 #2
0
ファイル: main.c プロジェクト: afester/CodeSamples
void processMenu() {
    uint8_t c = 0;
    uint8_t current = 0;

    cursor(0);
    while(1) {
        renderMenu(current);

        c = cgetc();
        if (c == 157) {
            // Left
            if (current == 0) {
                current = menuSize - 1;
            } else {
                current--;
            }
        } else if (c == 29) {
            // Right
            current++;
            if (current >= menuSize) {
                current = 0;
            }
        } else if (c == 3) {
            break;
        }
    }

    renderMenu(100);
    cursor(1);
    revers(0);
}
コード例 #3
0
ファイル: main.c プロジェクト: afester/CodeSamples
int main() {
    clrscr();
    bordercolor(0);
    bgcolor(6);

    renderMenu(100);

    textcolor(7);
    gotoxy(0, 1);
    updateStatus(' ');
    cursor(1);
    while(1) {
        char c;
/*
        uint8_t row;
        uint8_t col;
        for (row = 0;  row < 16;  row++) {
            gotoxy(0, row + 3);
            cprintf("%3d ", row * 16);
            for (col = 0;  col < 16;  col++) {
                cputc(row * 16 + col);
                cputc(' ');
            }
        }
*/
        c = cgetc();

        if (c == 20) {
            // backspace
        } else if (c == 13) {
            // Return
        } else if (c == 157) {
            // Left
            uint8_t xpos = wherex() - 1;
            gotox(xpos);
        } else if (c == 29) {
            // Right
            uint8_t xpos = wherex() + 1;
            gotox(xpos);
        } else if (c == 17) {
            // Down
            uint8_t ypos = wherey() + 1;
            gotoy(ypos);
        } else if (c == 145) {
            // Up
            uint8_t ypos = wherey() - 1;
            gotoy(ypos);
        } else if (c == 19) {
            // Pos1
        } else if (c == 3) {
            // ESC -> Menu
            processMenu();
        } else {
            cputc(c);
        }        

        
        updateStatus(c);
    }
}
コード例 #4
0
ファイル: Postmortem.cpp プロジェクト: jachamp/ia
void Postmortem::readKeysMenu(const vector<StrAndClr>& linesAndClr,
                              bool* const quitGame) {
  MenuBrowser browser(5, 0);

  renderMenu(browser);

  bool done = false;
  while(done == false) {
    const MenuAction action = eng.menuInputHandler->getAction(browser);
    switch(action) {
      case MenuAction::browsed: {
        renderMenu(browser);
      } break;

      case MenuAction::esc: {
        *quitGame = true;
        done      = true;
      } break;

      case MenuAction::space:
      case MenuAction::selectedShift: {} break;

      case MenuAction::selected: {
        if(browser.isPosAtElement(0)) {
          runInfo(linesAndClr);
          renderMenu(browser);
        }
        if(browser.isPosAtElement(1)) {
          eng.highScore->runHighScoreScreen();
          renderMenu(browser);
        }
        if(browser.isPosAtElement(2)) {
          eng.log->displayHistory();
          renderMenu(browser);
        }
        if(browser.isPosAtElement(3)) {
          done = true;
        }
        if(browser.isPosAtElement(4)) {
          *quitGame = true;
          done      = true;
        }
      } break;
    }
  }
}
コード例 #5
0
ファイル: Postmortem.cpp プロジェクト: ronw23/ia-osx
void Postmortem::readKeysMenu(bool* const quitGame) {
  MenuBrowser browser(5, 0);

  renderMenu(browser);

  bool done = false;
  while(done == false) {
    const MenuAction_t action = eng->menuInputHandler->getAction(browser);
    switch(action) {
    case menuAction_browsed: {
      renderMenu(browser);
    }
    break;
    case menuAction_canceled: {
    }
    break;
    case menuAction_selected: {
      if(browser.isPosAtKey('a')) {
        runInfo();
        renderMenu(browser);
      }
      if(browser.isPosAtKey('b')) {
        eng->highScore->runHighScoreScreen();
        renderMenu(browser);
      }
      if(browser.isPosAtKey('c')) {
        eng->log->displayHistory();
        renderMenu(browser);
      }
      if(browser.isPosAtKey('d')) {
        done = true;
      }
      if(browser.isPosAtKey('e')) {
        *quitGame = true;
        done = true;
      }
    }
    break;
    case menuAction_selectedWithShift:
    {} break;
    }
  }
}
コード例 #6
0
ファイル: menu.c プロジェクト: ColinDuquesnoy/ProjUF02
void mnuDisplay(struct Menu *mnu)
{
    Bool exit = False;
    uiShowCursor(False);
    // enable arrow keys
    keypad(stdscr, TRUE);
    // disable line buffering
    raw();
    while(!exit)
    {
        Int32 lastPos = -1;
        if(lastPos != mnu->currentPos)
            renderMenu(mnu);
        lastPos = mnu->currentPos;
        exit = updateMenu(mnu);
    }
    uiShowCursor(True);
}
コード例 #7
0
ファイル: kernel_menu.c プロジェクト: Mithrandir0x/pae
static void onMenuUpdate()
{
    F_PTR callback;

    if ( __kernel_menu_updateMenu )
    {
        __kernel_menu_updateMenu = FALSE;
        renderMenu();
    }
    else if ( __kernel_menu_updateTick )
    {
        __kernel_menu_updateTick = FALSE;
        renderTickle();
    }

    if ( __kernel_menu_initializeProgram )
    {
        callback = __kernel_menu_programs[__kernel_menu_selectedProgram].onProgramInitializeCallback;
        if ( callback != NULL ) callback();

        __kernel_menu_initializeProgram = FALSE;
    }
}
コード例 #8
0
ファイル: main.c プロジェクト: DavidSM64/Minicraft3DS
int main() {
    cfguInit();
    CFGU_GetSystemModel(&MODEL_3DS);
	FILE * file;
	shouldRenderDebug = true;
	if ((file = fopen("settings.bin", "r"))) {
        fread(&shouldRenderDebug,sizeof(bool),1,file);
        fread(&shouldSpeedup,sizeof(bool),1,file);
        osSetSpeedupEnable(shouldSpeedup);
		fclose(file);
	}
    
	sf2d_init();
	csndInit();
	noItem = newItem(ITEM_NULL, 0);
	
	currentMenu = MENU_TITLE;
	currentSelection = 0;
	quitGame = false;

	icons = sfil_load_PNG_buffer(icons2_png, SF2D_PLACE_RAM);
	font = sfil_load_PNG_buffer(Font_png, SF2D_PLACE_RAM);
	bottombg = sfil_load_PNG_buffer(bottombg_png, SF2D_PLACE_RAM);
	
	dirtColor[0] = SWAP_UINT32(sf2d_get_pixel(icons, 16, 0)); 
	dirtColor[1] = SWAP_UINT32(sf2d_get_pixel(icons, 16, 1)); 
	dirtColor[2] = SWAP_UINT32(sf2d_get_pixel(icons, 16, 2)); 
	dirtColor[3] = SWAP_UINT32(sf2d_get_pixel(icons, 16, 3)); 
	dirtColor[4] = SWAP_UINT32(sf2d_get_pixel(icons, 16, 4)); 

	loadSound(&snd_playerHurt, "resources/playerhurt.raw");
	loadSound(&snd_playerDeath, "resources/playerdeath.raw");
	loadSound(&snd_monsterHurt, "resources/monsterhurt.raw");
	loadSound(&snd_test, "resources/test.raw");
	loadSound(&snd_pickup, "resources/pickup.raw");
	loadSound(&snd_bossdeath, "resources/bossdeath.raw");
	loadSound(&snd_craft, "resources/craft.raw");
	
	bakeLights();
	
	int i;
	for (i = 0; i < 5; ++i) {
		minimap[i] = sf2d_create_texture(128, 128, TEXFMT_RGBA8,
				SF2D_PLACE_RAM);
		sf2d_texture_tile32(minimap[i]);
	}
	
	sf2d_set_vblank_wait(true);

	sf2d_set_clear_color(0xFF000000);

	k_up.input = KEY_DUP | KEY_CPAD_UP | KEY_CSTICK_UP;
	k_down.input = KEY_DDOWN | KEY_CPAD_DOWN | KEY_CSTICK_DOWN;
	k_left.input = KEY_DLEFT | KEY_CPAD_LEFT | KEY_CSTICK_LEFT;
	k_right.input = KEY_DRIGHT | KEY_CPAD_RIGHT | KEY_CSTICK_RIGHT;
	k_attack.input = KEY_A | KEY_B | KEY_L | KEY_ZR;
	k_menu.input = KEY_X | KEY_Y | KEY_R | KEY_ZL;
	k_pause.input = KEY_START;
	k_accept.input = KEY_A;
	k_decline.input = KEY_B;
	k_delete.input = KEY_X;
	k_menuNext.input = KEY_R;
	k_menuPrev.input = KEY_L;

	if ((file = fopen("btnSave.bin", "rb"))) {
		fread(&k_up.input, sizeof(int), 1, file);
		fread(&k_down.input, sizeof(int), 1, file);
		fread(&k_left.input, sizeof(int), 1, file);
		fread(&k_right.input, sizeof(int), 1, file);
		fread(&k_attack.input, sizeof(int), 1, file);
		fread(&k_menu.input, sizeof(int), 1, file);
		fread(&k_pause.input, sizeof(int), 1, file);
		fread(&k_accept.input, sizeof(int), 1, file);
		fread(&k_decline.input, sizeof(int), 1, file);
		fread(&k_delete.input, sizeof(int), 1, file);
		fread(&k_menuNext.input, sizeof(int), 1, file);
		fread(&k_menuPrev.input, sizeof(int), 1, file);
		fclose(file);
	}
	
	if ((file = fopen("lastTP.bin", "r"))) {
		char fnbuf[256];
		fgets(fnbuf, 256, file); // get directory to texturepack
		loadTexturePack(fnbuf);   
		fclose(file);
	}

	tickCount = 0;
	initRecipes();
	defineTables();
	while (aptMainLoop()) {
		++tickCount;
		hidScanInput();
		tickKeys(hidKeysHeld(), hidKeysDown());

		if (quitGame) break;

		if (initGame > 0) setupGame(initGame == 1 ? true : false);

		if (currentMenu == 0) {
			tick();
			sf2d_start_frame(GFX_TOP, GFX_LEFT);

			offsetX = xscr;
			offsetY = yscr;
			sf2d_draw_rectangle(0, 0, 400, 240, 0xFF0C0C0C); //RGBA8(12, 12, 12, 255)); //You might think "real" black would be better, but it actually looks better that way
			renderLightsToStencil();

			renderBackground(xscr, yscr);
			renderEntities(player.x, player.y, &eManager);
			renderPlayer();
			
			resetStencilStuff();
			offsetX = 0;
			offsetY = 0;
			
			if(shouldRenderDebug){
			    sprintf(fpsstr, " FPS: %.0f, X:%d, Y:%d, E:%d", sf2d_get_fps(), player.x, player.y, eManager.lastSlot[currentLevel]);
			    drawText(fpsstr, 2, 225);
            }
			
			sf2d_end_frame();

            sf2d_start_frame(GFX_BOTTOM, GFX_LEFT);
                if(!shouldRenderMap){
                    sf2d_draw_texture(bottombg, 0, 0);
                    renderGui();
                } else {
                    renderZoomedMap();
                }
            sf2d_end_frame();
		} else {
			tickMenu(currentMenu);
			renderMenu(currentMenu, xscr, yscr);
		}

		sf2d_swapbuffers();
	}

	freeRecipes();

	freeLightBakes();
	sf2d_free_texture(icons);
	sf2d_free_texture(minimap[0]);
	sf2d_free_texture(minimap[1]);
	sf2d_free_texture(minimap[2]);
	sf2d_free_texture(minimap[3]);
	sf2d_free_texture(minimap[4]);
	freeSounds();
	csndExit();
    cfguExit();
	sf2d_fini();
	return 0;
}
コード例 #9
0
ファイル: main.c プロジェクト: shutterbug2000/Minicraft3DS
int main()
{
	sf2d_init();
	csndInit();
	noItem = newItem(ITEM_NULL,0);
	
	currentMenu = MENU_TITLE;
    currentSelection = 0;
	quitGame = false;

    icons = sfil_load_PNG_buffer(icons2_png, SF2D_PLACE_RAM);
    font = sfil_load_PNG_buffer(Font_png, SF2D_PLACE_RAM);
	
	//consoleInit(GFX_BOTTOM, NULL);
   // printf("Press 'Start' to exit.\n");

	loadSound(&snd_playerHurt, "resources/playerhurt.raw");
	loadSound(&snd_playerDeath, "resources/playerdeath.raw");
	loadSound(&snd_monsterHurt, "resources/monsterhurt.raw");
	loadSound(&snd_test, "resources/test.raw");
	loadSound(&snd_pickup, "resources/pickup.raw");
	loadSound(&snd_bossdeath, "resources/bossdeath.raw");
	loadSound(&snd_craft, "resources/craft.raw");
    
    int i;
    for(i = 0;i < 5;++i){
       minimap[i] = sf2d_create_texture(128,128,TEXFMT_RGBA8,SF2D_PLACE_RAM);
	   sf2d_texture_tile32(minimap[i]);
    }
    
    sf2d_set_vblank_wait(true);
	
	sf2d_set_clear_color(0xFF);
	
	/* Default inputs */
	k_up.input = KEY_DUP | KEY_CPAD_UP | KEY_CSTICK_UP;
	k_down.input = KEY_DDOWN | KEY_CPAD_DOWN | KEY_CSTICK_DOWN;
	k_left.input = KEY_DLEFT | KEY_CPAD_LEFT | KEY_CSTICK_LEFT;
	k_right.input = KEY_DRIGHT | KEY_CPAD_RIGHT | KEY_CSTICK_RIGHT;
	k_attack.input = KEY_A | KEY_B | KEY_L | KEY_ZR;
	k_menu.input = KEY_X | KEY_Y | KEY_R | KEY_ZL;
	k_pause.input = KEY_START;
    k_accept.input = KEY_A;
    k_decline.input = KEY_B;
    k_delete.input = KEY_X;
    FILE * file;
    
    /* If btnSave exists, then use that. */
    if ((file = fopen("btnSave.bin", "rb"))){
        fread(&k_up.input, sizeof(int), 1, file);
        fread(&k_down.input, sizeof(int), 1, file);
        fread(&k_left.input, sizeof(int), 1, file);
        fread(&k_right.input, sizeof(int), 1, file);
        fread(&k_attack.input, sizeof(int), 1, file);
        fread(&k_menu.input, sizeof(int), 1, file);
        fread(&k_pause.input, sizeof(int), 1, file);
        fread(&k_accept.input, sizeof(int), 1, file);
        fread(&k_decline.input, sizeof(int), 1, file);
        fread(&k_delete.input, sizeof(int), 1, file);
        fclose(file);
    }
	
	//screenShot = false;
	
    tickCount=0;
    initRecipes();
    defineTables();
	while (aptMainLoop()) {
		++tickCount;
		hidScanInput();
		tickKeys(hidKeysHeld(),hidKeysDown());

		//if (quitGame || hidKeysHeld() & KEY_SELECT) break;
		if (quitGame) break;
		//if (hidKeysDown() & (KEY_L | KEY_R)) screenShot = true;
	//	else screenShot = false;
        
        if(initGame > 0) setupGame(initGame == 1 ? true : false);
        
        if(currentMenu == 0){
            tick();
            sprintf(fpsstr, " FPS: %.0f, X:%d, Y:%d, E:%d", sf2d_get_fps(),player.x, player.y,eManager.lastSlot[currentLevel]);
		    sf2d_start_frame(GFX_TOP, GFX_LEFT);
                if(currentLevel == 0){ 
                    sf2d_draw_texture_part_scale(minimap[1],(-xscr/3)-256,(-yscr/3)-32,0,0,128,128,12.5,7.5);
                    sf2d_draw_rectangle(0,0,400,240, 0xDFDFDFAF);
                }
	            offsetX = xscr;offsetY = yscr;
		        renderBackground(xscr,yscr);
		        renderEntities(player.x, player.y, &eManager);
		        renderPlayer();
	            offsetX = 0;offsetY = 0;
		        renderItemWithText(player.p.activeItem, 10, 205);
		       // drawText(debugText,2,208);
		        drawText(fpsstr,2,225);
		    sf2d_end_frame();
		      
		    sf2d_start_frame(GFX_BOTTOM, GFX_LEFT);	
		        if(currentLevel == 0 && airWizardHealthDisplay > 0){ 
                    sprintf(bossHealthText, "BOSS: %.0f%%", ((float)airWizardHealthDisplay/2000.0)*100);
                    drawText(bossHealthText,2,225);
                }
		        renderGui();
                sf2d_draw_texture(minimap[currentLevel], 192, 112);//y:56
            sf2d_end_frame();
        } else{ 
            tickMenu(currentMenu);
            renderMenu(currentMenu,xscr,yscr);
        }
        
		sf2d_swapbuffers();
	}
	
    freeRecipes();
	sf2d_free_texture(icons);
	sf2d_free_texture(minimap[0]);
	sf2d_free_texture(minimap[1]);
	sf2d_free_texture(minimap[2]);
	sf2d_free_texture(minimap[3]);
	sf2d_free_texture(minimap[4]);
    freeSounds();
    csndExit();
	sf2d_fini();
	return 0;
}
コード例 #10
0
ファイル: main.c プロジェクト: djeck/SixPrend
int main(int argc, char ** argv)
{
    srand(time(NULL));

    printf("main: lancement du jeu\n");

    init(); // initialisation des ressources communes à toute partie du jeu

    printf("main: initialisation des ressources graphiques du login\n");
    changeStep(login);

    printf("main: début de la boucle de rendu\n");
    while (globalStep!=end)
    {
        SDL_RenderClear(renderer);
        switch(globalStep)
        {
        case login:
            renderLogin();// on dessine le login
            break;
        case menu:
            renderMenu();
            break;
        case mode:
            renderMode();
            break;
        case stat:
            renderStat();
            break;
        case game:
            renderGame();
            break;
        case end:
            break;
        default:
            printf("main: globalState non valide\n");
        }

        SDL_RenderPresent(renderer);

        //SDL_Delay(5); // provisoire afin de ne pas utiliser tout le cpu

        switch(globalStep)
        {
        case login:
            eventLogin();
            break;
        case menu:
            eventMenu();
            break;
        case mode:
            eventMode();
            break;
        case stat:
            eventStat();
            break;
        case game:
            eventGame();
            break;
        case end:
            break;
        default:
            printf("main: globalState non valide\n");

        }
    }

    //free ressource
    printf("main: liberation des ressources\n");
    quit();// liberation des ressources communes
    printf("main: fin du jeu\n");
    return 0;
}