Ejemplo n.º 1
0
void ckvdSingleColorGrabber::draw()
{
    ofPushStyle();
    
    ofSetColor(_color);
    ofFill();
    ofRect(x-width/2, y-height/2, width, height);
    
    if (isFocused())
    {
        ofSetColor(255, 255, 100);
        drawCrosshair(x, y, width, height, 5);
        ofSetColor(60, 60, 60);
        drawCrosshair(x, y, width, height, 1);
        ofSetColor(255, 255, 100);
    }
    else
    {
        ofSetColor(255, 255, 255);
        drawCrosshair(x, y, width, height, 1);
    }
    
    if (theApp()->getGrabberFont())
    {
        theApp()->getGrabberFont()->drawString(_fixture.getName(), x+width/2+3, y-height/2+3);
    }
    
    ofPopStyle();
}
Ejemplo n.º 2
0
void Player::draw2Self()
{
	glDisable( GL_LIGHTING );
	glDisable( GL_TEXTURE_2D );

	glPushAttrib( GL_DEPTH_BUFFER_BIT );
	glDisable( GL_DEPTH_TEST );

	glPushMatrix();
	glLoadIdentity();

	switch( state() )
	{
		case SPAWNING:
			break;
		case ALIVE:
			drawCrosshair();
			break;
		case DYING:
			break;
		case DEAD:
			break;
	}

	glPopMatrix();

	glPopAttrib();
}
Ejemplo n.º 3
0
void drawHud() {
	char printBuff[256];

	// Draw Crosshair (in 2D)
	drawCrosshair(viewWidth, viewHeight);

	// Draw Height Measurement Bar
	drawHeightHud(HUD_HEIGHT_BAR_X, HUD_HEIGHT_BAR_Y, heightValue);

	// Draw Roll
	drawRollHud(HUD_ROLL_X, HUD_ROLL_Y, HUD_ROLL_RADIUS, rollValue);
	
	// Draw Pitch
	drawPitchHud(HUD_PITCH_X, HUD_PITCH_Y, HUD_PITCH_RADIUS, pitchValue);

	// Draw helper window
	if (showHelp) {
		drawKeyboardHelp(10, viewHeight-30);
	}

	// Draw Top Down Map
	topDownMap.draw();

	if (editPlacing) {
		drawPlacingHelp(viewWidth-10,10);
		drawModelInfo(viewWidth-10, viewHeight-30);
	}
}
Ejemplo n.º 4
0
void TankController::drawHUD(UI::IMGUI &ui){
	crosshair = glm::mix(crosshair, Global::main.center - 3.f*KeyState::mouseTranslation, 0.08);


	ui.table(UI::LayoutVertical | UI::AlignLeft | UI::AlignTop )
		.overridePosition(Global::main.size.x-160, Global::main.size.y - 2);
	auto &motor = tankMechanics->motor;
	ui.rect(150, 20).color(color::white).text("speed: "+std::to_string(motor.params.speed))();
	ui.rect(150, 20).color(color::white).text("torque: "+std::to_string(motor.params.torque))();
	ui.rect(150, 20).color(color::white).text("gear: "+std::to_string(motor.params.gear))();
	ui.rect(150, 20).color(color::white).text("throttle: "+std::to_string(motor.params.throttle))();
	ui.rect(150, 20).color(color::white).text("clutch: "+std::to_string(motor.params.clutch))();
	ui.rect(150, 20).color(color::white).text("rpm: "+std::to_string(motor.params.rpm))();
	ui.rect(150, 20).color(color::white).text("inputRpm: "+std::to_string(motor.params.inputRpm))();
	ui.rect(150, 20).color(color::white).text("hp: "+std::to_string(motor.params.hp))();
	ui.endTable();


	/// TODO:100 switch on camera type,
	drawCrosshair(*this, ui);
	if(hudData.tank.weapon)
	switch(hudData.tank.weapon->type){
		case armory::WeaponType::Ballistic : showWeaponInfo(*this, (armory::BallisticWeapon*) hudData.tank.weapon, ui); break;
		case armory::WeaponType::Laser : showWeaponInfo(*this, (armory::LaserWeapon*) hudData.tank.weapon, ui); break;
		case armory::WeaponType::Kinetic : break;
	}

}
static gboolean onExposeExonView(GtkWidget *exonView, GdkEventExpose *event, gpointer data)
{
  GdkDrawable *drawable = widgetGetDrawable(exonView);
  
  if (!drawable)
    {
      /* Create a pixmap and draw the exon view onto it */
      drawable = createBlankPixmap(exonView);
      drawExonView(exonView, drawable);
    }
  
  if (drawable)
    {  
      /* Push the pixmap onto the screen */
      GdkDrawable *window = GTK_LAYOUT(exonView)->bin_window;
      
      GdkGC *gc = gdk_gc_new(window);

      gdk_draw_drawable(window, gc, drawable, 0, 0, 0, 0, -1, -1);

      /* Draw the crosshair over the top */
      drawCrosshair(exonView, window, gc);
      
      g_object_unref(gc);
    }


  return TRUE;
}
/* Prepare the exon view for printing. Draws the crosshair onto the cached
 * drawable. (Normally it is drawn directly to screen in the expose function.) */
void exonViewPrepareForPrinting(GtkWidget *exonView)
{
  GdkDrawable *drawable = widgetGetDrawable(exonView);
  
  if (!drawable)
    {
      drawable = createBlankPixmap(exonView);
      drawExonView(exonView, drawable);
    }
  
  if (drawable)
    {
      GdkGC *gc = gdk_gc_new(drawable);
      drawCrosshair(exonView, drawable, gc);
      g_object_unref(gc);
    }
}
Ejemplo n.º 7
0
void Game::play()
{
	extern char const *gameTitle;

	sf::RenderWindow window(sf::VideoMode(W_WIDTH, W_HEIGHT, 32), gameTitle,
							/*sf::Style::Titlebar | sf::Style::Close*/ 0,
							sf::ContextSettings(24, 8, 4, 2, 0)); // turn on antialiasing

	init(window);
	EntityManager entManager;
	//entManager.addEntity(sf::Vector2f(50, 50));
	//entManager.addEntity(sf::Vector2f(100, 50));
	//entManager.addEntity(sf::Vector2f(150, 50));

	if(!shader.loadFromMemory(vs, fs))
		throw E_SHADER_INIT_FAILURE;

	sf::Clock clk;
	while(window.isOpen())
	{
		InputState state = handleEvents(window);

		shader.setParameter("clk", clk.getElapsedTime().asSeconds());
		shader.setParameter("fire", player.getVel());
		shader.setParameter("colorMod", player.getFireMod());
		window.draw(backSurface, &shader);

		bManager.updateBullets(window);
		entManager.updateEntities(window, bManager, clk, player.getPos());

		player.update(window, bManager, clk.getElapsedTime(),
					  state.leftMouse, state.rightMouse);
		window.draw(player);

		drawCrosshair(window);
		window.display();
	}
}
Ejemplo n.º 8
0
int main(int argc, char *argv[]) {
    font_t *font;
    const texture_t *texture;
    const texture_t *misc;
    flubSlice_t *dlg_body;
    flubSlice_t *dlg_title;
    eCmdLineStatus_t status;
    int keepGoing = 1;
    Uint32 lastTick;
    Uint32 current;
    Uint32 elapsed;
    SDL_Event ev;
    int eventCount;
    FILE *fp;
    eThemerState_t state = eThemerStateType;
    tsMenuState_t menuState;
    tsMenuEntry_t menuEntries[] = {
            {"Bitmap", eCompBitmap},
            {"Animation", eCompAnimation},
            {"Tile", eCompTile},
            {"Slice", eCompSlice},
            {NULL, 0},
        };
    int pos = 0;
    int curx = 0;
    int cury = 0;
    compState_t parentComp, *comp, *walk;
    flubSimpleEdit_t *edit;
    const char *path = "flub-theme.txt";
    appCmdlineCtx_t appCtx = {.path = NULL};

    if(!appInit(argc, argv)) {
        return 1;
    }

    // Register command line params and config vars

    if((status = appStart(&appCtx)) != eCMDLINE_OK) {
        return ((status == eCMDLINE_EXIT_SUCCESS) ? 0 : 1);
    }
    if(appCtx.path != NULL) {
        path = appCtx.path;
    }

    if((fp = fopen(path, "a+t")) == NULL) {
        errorf("Failed to open theme output file.");
        return 1;
    } else {
        infof("Opened output file \"%s\"", path);
    }

    if((font = fontGet("consolas", 12, 0)) == NULL) {
        infof("Unable to get font");
        return 1;
    }

    texture = texmgrGet("flub-simple-gui");
    misc = texmgrGet("flub-keycap-misc");
    dlg_body = gfxSliceCreate(misc, 41, 29, 43, 30, 60, 40, 62, 42);
    dlg_title = gfxSliceCreate(misc, 41, 17, 43, 19, 60, 26, 62, 28);

    inputActionBind("KEY_BACKQUOTE", "showconsole");

    tsMenuInit(&menuState, font, menuEntries, 310, 45);
    edit = flubSimpleEditCreate(font, 30, 310, 70);
    tsCompStateInit(&parentComp, texture, menuState.pos);
    comp = &parentComp;

    lastTick = SDL_GetTicks();
    while (keepGoing) {
        current = SDL_GetTicks();
        elapsed = current - lastTick;
        lastTick = current;

        tsCompAnimUpdate(comp, elapsed);

        eventCount = 0;
        while(inputPollEvent(&ev)) {
            eventCount++;
            if(ev.type == SDL_QUIT) {
                keepGoing = 0;
                break;
            }

            if(ev.type == SDL_KEYDOWN) {
                if(ev.key.keysym.sym == SDLK_ESCAPE) {
                    state = eThemerStateConfirm;
                    break;
                } else if(ev.key.keysym.sym == SDLK_HOME) {
                    videoScreenshot("screenshot");
                    break;
                }
            }

            switch(state) {
                default:
                case eThemerStateType:
                    if(tsMenuInput(&menuState, &ev)) {
                        state = eThemerStatePoints;
                        comp = tsCompStateClear(comp);
                        curx = 0;
                        cury = 0;
                        tsCompStateInit(comp, texture, menuState.pos);
                    }
                    break;
                case eThemerStatePoints:
                    if(ev.type == SDL_KEYDOWN) {
                        switch (ev.key.keysym.sym) {
                            case SDLK_END:
                                flubSimpleEditSet(edit, "comp");
                                flubSimpleEditActive(edit, 1);
                                state = eThemerStateName;
                                break;
                            case SDLK_INSERT:
                                comp = tsCompStateAddFrame(comp);
                                break;
                            case SDLK_EQUALS:
                                comp = tsCompFrameNext(comp);
                                break;
                            case SDLK_BACKSLASH:
                                tsCompAnimToggle(comp);
                                break;
                            case SDLK_PAGEUP:
                                if(ev.key.keysym.mod & KMOD_SHIFT) {
                                    tsCompAnimAdjust(comp, 10);
                                } else {
                                    tsCompAnimAdjust(comp, 1);
                                }
                                break;
                            case SDLK_PAGEDOWN:
                                if(ev.key.keysym.mod & KMOD_SHIFT) {
                                    tsCompAnimAdjust(comp, -10);
                                } else {
                                    tsCompAnimAdjust(comp, -1);
                                }
                                if(comp->delay < 0) {
                                    comp->delay = 0;
                                }
                                break;
                            case SDLK_UP:
                                tsCompPosUpdate(comp, 0, -1,
                                                ((ev.key.keysym.mod & KMOD_SHIFT) ? 1 : 0),
                                                ((ev.key.keysym.mod & KMOD_CTRL) ? 1 : 0),
                                                &curx, &cury);
                                break;
                            case SDLK_DOWN:
                                tsCompPosUpdate(comp, 0, 1,
                                                ((ev.key.keysym.mod & KMOD_SHIFT) ? 1 : 0),
                                                ((ev.key.keysym.mod & KMOD_CTRL) ? 1 : 0),
                                                &curx, &cury);
                                break;
                            case SDLK_LEFT:
                                tsCompPosUpdate(comp, -1, 0,
                                                ((ev.key.keysym.mod & KMOD_SHIFT) ? 1 : 0),
                                                ((ev.key.keysym.mod & KMOD_CTRL) ? 1 : 0),
                                                &curx, &cury);
                                break;
                            case SDLK_RIGHT:
                                tsCompPosUpdate(comp, 1, 0,
                                                ((ev.key.keysym.mod & KMOD_SHIFT) ? 1 : 0),
                                                ((ev.key.keysym.mod & KMOD_CTRL) ? 1 : 0),
                                                &curx, &cury);
                                break;
                            case SDLK_RETURN:
                                tsCompNextPoint(comp, &curx, &cury);
                                break;
                        }
                    }
                    break;
                case eThemerStateName:
                    if(flubSimpleEditInput(edit, &ev)) {
                        // Save the entry
                        if(comp->type == eCompSlice) {
                            fprintf(fp,"%s %d %d %d %d %d %d %d %d\n", edit->buf,
                                    comp->pos[0][0], comp->pos[0][1],
                                    comp->pos[1][0], comp->pos[1][1],
                                    comp->pos[2][0], comp->pos[2][1],
                                    comp->pos[3][0], comp->pos[3][1]);
                        } else if(comp->type == eCompAnimation) {
                            fprintf(fp, "%s %d %d ", edit->buf,
                                    (comp->pos[1][0] - comp->pos[0][0] + 1),
                                    (comp->pos[1][1] - comp->pos[0][1]));
                            if(comp->parent == NULL) {
                                walk = comp;
                            } else {
                                walk = comp->parent;
                            }
                            for(; walk != NULL; walk = walk->next) {
                                fprintf(fp, "%d %d %d ", walk->pos[0][0], walk->pos[0][1], walk->delay);
                            }
                        } else {
                            fprintf(fp,"%s %d %d %d %d\n", edit->buf,
                                    comp->pos[0][0], comp->pos[0][1],
                                    comp->pos[1][0], comp->pos[1][1]);
                        }
                        state = eThemerStateType;
                        break;
                    }
                    break;
                case eThemerStateConfirm:
                    if(ev.type == SDL_KEYDOWN) {
                        switch (ev.key.keysym.sym) {
                            case SDLK_END:
                                keepGoing = 0;
                                break;
                            case SDLK_RETURN:
                                state = eThemerStateType;
                                break;
                        }
                        break;
                    }
                    break;
            }
            if(eventCount >= BULK_EVENT_LIMIT) {
                break;
            }
        }
        videoClear();

        videoPushGLState();
        videoOrthoMode();

        glLoadIdentity();
        glColor3f(1.0, 1.0, 1.0);

        // Title
        gfxSliceBlit(dlg_title, 0, 0, 639, 20);
        fontMode();
        fontPos(5, 5);
        fontSetColor(0.0, 0.0, 0.0);
        fontBlitStr(font, "Flub Themer");

        // Image
        glLoadIdentity();
        drawTexture(texture, 10, 30);

        // State name
        fontMode();
        fontSetColor(1.0, 1.0, 1.0);
        fontPos(300, 25);

        switch(state) {
            default:
            case eThemerStateType:
                fontBlitStr(font, "Select component type:");
                tsMenuDraw(&menuState);
                break;
            case eThemerStatePoints:
                fontBlitStr(font, "Select points:");
                drawFragment(texture, dlg_body, comp);
                drawCrosshair(misc, curx + 10, cury + 30);
                fontMode();
                fontPos(5, 300);
                fontSetColor(1.0, 1.0, 1.0);
                fontBlitStrf(font, "X: %3d  Y: %3d", curx, cury);
                tsCompPointInfo(comp, font, 310, 50);
                if((comp->type == eCompAnimation) &&
                   (((comp->parent != NULL) && (comp->parent->animGo)) ||
                    (comp->animGo))) {
                    fontPos(310, 250);
                    fontSetColor(1.0, 1.0, 1.0);
                    fontBlitStrf(font, "Animating");
                }
                break;
            case eThemerStateName:
                fontBlitStr(font, "Select component type:");
                fontMode();
                fontPos(310, 50);
                fontSetColor(1.0, 1.0, 1.0);
                fontBlitStr(font, "Enter component name");
                flubSimpleEditDraw(edit);
                break;
            case eThemerStateConfirm:
                fontBlitStr(font, "Are you sure you want to quit?");
                gfxBlitKeyStr(font, "Press [End] to exit, [Return] to continue.", 310, 50, NULL, NULL);
                break;
        }

        if(!appUpdate(current)) {
            keepGoing = 0;
        }
    }
    fclose(fp);
    return 0;
}
void Tanks_single::drawHUD(){
    glDisable ( GL_LIGHTING );
    glColor3f( 0.0f, 1.0f, 0.0f );
    drawCrosshair( 10 );
}