Exemple #1
0
// Player pressed da button.
func ObjectControl(int plr, int ctrl, int x, int y, int strength, bool repeat, bool release)
{
	if (release) return true;
	var xdir=0, ydir=0, comd;
	if (ctrl == CON_Up)
		{ ydir = -1; comd = COMD_Up; }
	else if (ctrl == CON_Down)
		{ ydir = +1; comd = COMD_Down; }
	else if (ctrl == CON_Left)
		{ xdir = -1; comd = COMD_Left; }
	else if (ctrl == CON_Right)
		{ xdir = +1; comd = COMD_Right; }
	else
		return true; // block anything else
	var is_drawing = (GetAction() == "Draw");
	// No direct turnaround
	if (is_drawing && xdir * GetXDir() + ydir * GetYDir() < 0) { Sound("GIDL_Clonk::GIDLTurnError", true, 100, plr); return true; }
	Sound("GIDL_Clonk::GIDLTurn");
	var speed = ActMap.Draw.Speed / 10;
	if (is_drawing) Drawing();
	SetComDir(comd);
	if (is_drawing) { SetXDir(xdir*speed); SetYDir(ydir*speed); }
	SetR(Angle(0,0,xdir, ydir));
	return true;
}
void RadioButton::Render( Point pos, bool isSelected ) {
	const Rect& rect = GetRect();
	int x = rect.x + pos.x;
	int y = rect.y + pos.y;
	
	Control::Render(pos,isSelected);
	
	Drawing().Circle( x+RADIO_BUTTON_RADIUS, y+rect.h/2, RADIO_BUTTON_RADIUS, Color::White );
	if(tex_text) {
		Size s = tex_text->GetImageSize();
		// Drawing().TexRect( m_text_loc.x+pos.x, m_text_loc.y+pos.y+2, s.w, s.h, tex_text );
		Drawing().TexRect( m_text_loc.x+pos.x, pos.y+rect.y+rect.h/4, s.w, s.h, tex_text );
	}
	if(m_isSelected) {
		Drawing().FillCircle(x+RADIO_BUTTON_RADIUS, y+rect.h/2, RADIO_BUTTON_RADIUS-2, Color::Yellow );
	}
	
	
}
Exemple #3
0
/**
* Main.
* @param Pointer to the UNIVERSE.
* @return Success.
*/
int main(int argc, char *argv[])
{
    Initialize();
    LoadData();
    NewGame();
    
    while(running)
    {  
        Logic();
        Drawing();
    }

    Shutdown();
    
    return 0;
}
void TrackBar::Render( Point pos, bool isSelected ) {
	const Rect& rect = GetRect();
	int x = rect.x + pos.x;
	int y = rect.y + pos.y;
	
	Control::RenderBase(pos,isSelected);

	if(m_is_vertical) {
		int x2 = x + rect.w/2;
		Drawing().Line( x2, y, x2, y+rect.h, Color::White);
		if(m_marks > 0) {
			int dh = (float)rect.h / (float)m_marks;
			int y;
			for(int i=0; i <= m_marks; i++) {
				y = y + dh*i;
				Drawing().Line(x2-5, y, x2+5, y, Color::White);
			}
		}
		Drawing().FillCircle( x2, y + rect.h - m_slider_pix, m_slider_radius, m_on_it ? Color::Yellow : Color::White);
	} else {
		int h = y+rect.h/2;
		Drawing().Line(x, h, x+rect.w, h, Color::White);
		if(m_marks > 0) {
			float dw = (float)rect.w / (float)m_marks;
			for(int i=0; i <= m_marks; i++) {
				Drawing().Line(x + dw*i, h-5, x + dw*i, h+5, Color::White);
			}
		}
		Drawing().FillCircle( x + m_slider_pix, h, m_slider_radius, m_on_it ? Color::Yellow : Color::White);
	}
	
	Control::RenderWidget(pos,isSelected);
	
	if(tex_text != 0) {
		if(m_is_vertical) {
			pos.x += m_slider_radius+2;
			pos.y += m_slider_radius/2;
		} else {
			pos.y += m_slider_radius/2;
		}
		Drawing().TexRect(m_text_rect.x+pos.x, m_text_rect.y+pos.y, m_text_rect.w, m_text_rect.h, tex_text);
	}
	
}
void CRendering::ProcessFrame()
    {
    BeginDraw();
    Drawing(iRect);
    EndDraw();
    }
Exemple #6
0
void TextBox::Render( Point pos, bool selected ) {
	
	const Rect& rect = this->GetRect();
	const Point r = rect.Offset(pos);
	Control::RenderBase(pos, selected);
	
	int w,h;
	Drawing().GetResolution(w,h);
	
	// TODO: tweak clip region a little
	Drawing().PushClipRegion( r.x+2, r.y, m_text_area.w-5, m_text_area.h );
	
	int j;
	
	int sz=0;
	
	if(!m_lines.empty()) {
		// selection
		std::string piece = m_lines[m_cursor.y].text.utf8_substr(0, m_position.x, m_password);
		if(m_update_viewport) {
			sz = m_style.font->GetTextSize(piece);
			m_viewport_offset.x = sz;
			m_update_viewport = false;
		} else {
			sz = m_viewport_offset.x;
		}
		
		
		// draw selection if there is one
		if(m_anchor.x != -1) {
			j=0;
			Point p1,p2;
			sortPoints(p1,p2);
			int yy=m_position.y;
			for( auto i = m_lines.begin()+yy; i != m_lines.end(); i++,j++,yy++) {
				if(5+j*m_line_height+i->h > rect.h) break;
				if(yy < p1.y || yy > p2.y) continue;
				
				if(yy == p1.y && p1.y == p2.y) {
					std::string pd = m_lines[yy].text.utf8_substr(p1.x, p2.x-p1.x, m_password);
					std::string pd1 = m_lines[yy].text.utf8_substr(0, p1.x, m_password);
					
					int selw = m_style.font->GetTextSize( pd );
					int selw1 = m_style.font->GetTextSize( pd1 );
					
					Drawing().FillRect( r.x-sz+5+selw1, r.y+5+j*m_line_height, selw, i->h, m_selection_color);
				} else if(yy == p1.y) {
					std::string pd = m_lines[yy].text.utf8_substr(p1.x, std::string::npos, m_password);
					int selw = m_style.font->GetTextSize( pd );
					Drawing().FillRect( r.x-sz+5+i->w-selw, r.y+5+j*m_line_height, selw, i->h, m_selection_color);
				} else if(yy == p2.y) {
					std::string pd = m_lines[yy].text.utf8_substr(0, p2.x, m_password);
					int selw = m_style.font->GetTextSize( pd );
					Drawing().FillRect( r.x-sz+5, r.y+5+j*m_line_height, selw, i->h, m_selection_color);
				} else {
					Drawing().FillRect( r.x-sz+5, r.y+5+j*m_line_height, i->w, i->h, m_selection_color);
				}
			}
		}
		
		// placeholder or text
		if(!isActive() && m_lines.size() == 1 && !m_placeholder.text.empty() && m_lines[0].text.empty() ) {
			Drawing().TexRect( r.x+5, r.y+5, m_placeholder.w, m_placeholder.h, m_placeholder.tex);
		} else {
			j=0;
			if(m_position.y < m_lines.size()) {
				for( auto i = m_lines.begin()+m_position.y; i != m_lines.end(); i++,j++) {
					if(5+j*m_line_height+i->h > rect.h) break;
					if(i->h <= 1) continue;
					Drawing().TexRect( r.x-sz+5, r.y+5+j*m_line_height, i->w, i->h, i->tex);
				}
			}
		}
	}
	
	
	
	// cursor
	if(isActive() && !m_readonly && (m_cursor_blink_counter += getDeltaTime()) > m_cursor_blinking_rate && 
		m_cursor.y >= m_position.y && m_cursor.y-m_position.y < rect.h/m_line_height) {
		
		if(m_cursor_blink_counter > 2*m_cursor_blinking_rate) {
			m_cursor_blink_counter = 0;
		}
			
		if(m_cursor.x >= m_position.x && m_cursor.x <= m_lines[m_cursor.y].text.utf8_size()) {
			// std::string piece = m_lines[m_cursor.y].text.utf8_substr(m_position.x, m_cursor.x-m_position.x, m_password);
			std::string piece = m_lines[m_cursor.y].text.utf8_substr(0, m_cursor.x, m_password);
			Drawing().Rect(m_style.font->GetTextSize( piece )+r.x-sz+5, 
				(m_cursor.y-m_position.y)*m_line_height+r.y+5, 1, m_line_height, 0xffffffff);
		}
	}
	
	Drawing().PopClipRegion();
	
	RenderWidget(pos,selected);
	
}