예제 #1
0
파일: imgui.cpp 프로젝트: ZhuangChun/Box2D
bool imguiCollapse(const char* text, const char* subtext, bool checked, bool enabled)
{
	s_state.widgetId++;
	unsigned int id = (s_state.areaId << 16) | s_state.widgetId;

	int x = s_state.widgetX;
	int y = s_state.widgetY - BUTTON_HEIGHT;
	int w = s_state.widgetW;
	int h = BUTTON_HEIGHT;
	s_state.widgetY -= BUTTON_HEIGHT; // + DEFAULT_SPACING;

	const int cx = x + BUTTON_HEIGHT / 2 - CHECK_SIZE / 2;
	const int cy = y + BUTTON_HEIGHT / 2 - CHECK_SIZE / 2;

	bool over = enabled && inRect(x, y, w, h);
	bool res = buttonLogic(id, over);

	if (checked)
		AddGfxCmdTriangle(cx, cy, CHECK_SIZE, CHECK_SIZE, 2, SetRGBA(255, 255, 255, isActive(id) ? 255 : 200));
	else
		AddGfxCmdTriangle(cx, cy, CHECK_SIZE, CHECK_SIZE, 1, SetRGBA(255, 255, 255, isActive(id) ? 255 : 200));

	if (enabled)
		AddGfxCmdText(x + BUTTON_HEIGHT, y + BUTTON_HEIGHT / 2 - TEXT_HEIGHT / 2, TEXT_ALIGN_LEFT, text, isHot(id) ? SetRGBA(255, 196, 0, 255) : SetRGBA(255, 255, 255, 200));
	else
		AddGfxCmdText(x + BUTTON_HEIGHT, y + BUTTON_HEIGHT / 2 - TEXT_HEIGHT / 2, TEXT_ALIGN_LEFT, text, SetRGBA(128, 128, 128, 200));

	if (subtext)
		AddGfxCmdText(x + w - BUTTON_HEIGHT / 2, y + BUTTON_HEIGHT / 2 - TEXT_HEIGHT / 2, TEXT_ALIGN_RIGHT, subtext, SetRGBA(255, 255, 255, 128));

	return res;
}
예제 #2
0
파일: imgui.cpp 프로젝트: ZhuangChun/Box2D
bool imguiBeginScrollArea(const char* name, int x, int y, int w, int h, int* scroll)
{
	s_state.areaId++;
	s_state.widgetId = 0;
	g_scrollId = (s_state.areaId << 16) | s_state.widgetId;

	s_state.widgetX = x + SCROLL_AREA_PADDING;
	s_state.widgetY = y + h - AREA_HEADER + (*scroll);
	s_state.widgetW = w - SCROLL_AREA_PADDING * 4;
	g_scrollTop = y - AREA_HEADER + h;
	g_scrollBottom = y + SCROLL_AREA_PADDING;
	g_scrollRight = x + w - SCROLL_AREA_PADDING * 3;
	g_scrollVal = scroll;

	g_scrollAreaTop = s_state.widgetY;

	g_focusTop = y - AREA_HEADER;
	g_focusBottom = y - AREA_HEADER + h;

	g_insideScrollArea = inRect(x, y, w, h, false);
	s_state.insideCurrentScroll = g_insideScrollArea;

	AddGfxCmdRoundedRect((float)x, (float)y, (float)w, (float)h, 6, SetRGBA(0, 0, 0, 192));

	AddGfxCmdText(x + AREA_HEADER / 2, y + h - AREA_HEADER / 2 - TEXT_HEIGHT / 2, TEXT_ALIGN_LEFT, name, SetRGBA(255, 255, 255, 128));

	AddGfxCmdScissor(x + SCROLL_AREA_PADDING, y + SCROLL_AREA_PADDING, w - SCROLL_AREA_PADDING * 4, h - AREA_HEADER - SCROLL_AREA_PADDING);

	return g_insideScrollArea;
}
예제 #3
0
파일: imgui.cpp 프로젝트: ZhuangChun/Box2D
void imguiLabel(const char* text)
{
	int x = s_state.widgetX;
	int y = s_state.widgetY - BUTTON_HEIGHT;
	s_state.widgetY -= BUTTON_HEIGHT;
	AddGfxCmdText(x, y + BUTTON_HEIGHT / 2 - TEXT_HEIGHT / 2, TEXT_ALIGN_LEFT, text, SetRGBA(255, 255, 255, 255));
}
예제 #4
0
void MpColor::SetHSVA (int h, int s, int v, int alpha)
{
  float H(h/64), S(s/65535.0), V(v/65535.0), R,G,B;
  HSV_to_RGB (H,S,V, R,G,B);
  SetRGBA( uint32_t(R*65535),uint32_t(G*65535),uint32_t(B*65535),alpha);
  // color is un-allocated now
}
예제 #5
0
void MpColor::SetHSVA (float h, float s, float v, float alpha)
{
  float R,G,B;
  HSV_to_RGB (h,s,v, R,G,B);
  SetRGBA(R,G,B,alpha);
  // color is un-allocated now
}
예제 #6
0
MpColor::MpColor (int x, int y, int z, ColorSpace cs, int alpha)
{
  if (cs == RGB) 
    SetRGBA(x,y,z,alpha);
  else 
    SetHSVA(x,y,z,alpha);
}
예제 #7
0
void
ON_Color::SetFractionalRGBA( double red, double green, double blue, double alpha )
{
  int r,g,b,a;
	if (red   < 0.0 ) red   = 0.0; else if ( red   > 1.0 ) red   = 1.0;	
	if (green < 0.0 ) green = 0.0; else if ( green > 1.0 ) green = 1.0;	
	if (blue  < 0.0 ) blue  = 0.0; else if ( blue  > 1.0 ) blue  = 1.0;	
	if (alpha < 0.0 ) alpha = 0.0; else if ( alpha > 1.0 ) alpha = 1.0;

  red   *= 255.0;
  green *= 255.0;
  blue  *= 255.0;
  alpha *= 255.0;

  r = (int)red;
  g = (int)green;
  b = (int)blue;
  a = (int)alpha;

  // round to closest int
  if( (red-r)>=0.5 ) r++;
  if( (green-g)>=0.5 ) g++;
  if( (blue-b)>=0.5 ) b++;
  if( (alpha-a)>=0.5 ) a++;

  SetRGBA( r, g, b, a );
}
예제 #8
0
파일: imgui.cpp 프로젝트: ZhuangChun/Box2D
void imguiSeparatorLine()
{
	int x = s_state.widgetX;
	int y = s_state.widgetY - DEFAULT_SPACING * 2;
	int w = s_state.widgetW;
	int h = 1;
	s_state.widgetY -= DEFAULT_SPACING * 4;

	AddGfxCmdRect((float)x, (float)y, (float)w, (float)h, SetRGBA(255, 255, 255, 32));
}
예제 #9
0
MpColor::MpColor (const string &name, int a)
{
  int r,g,b;
  if (GetColorByName(name,r,g,b))
    SetRGBA(r,g,b,a);
  else {
    // invalid color
    flar = 0x00ff0000;
    gb  = 0x00000000;
    pix = 0xffffffff;
  }
}
예제 #10
0
void DebugDraw::DrawString(int x, int y, const char *string, ...)
{
	b2::float32 h = static_cast<b2::float32>(g_camera.m_height);

	char buffer[128];

	va_list arg;
	va_start(arg, string);
	std::vsprintf(buffer, string, arg);
	va_end(arg);

	AddGfxCmdText(float(x), h - float(y), TEXT_ALIGN_LEFT, buffer, SetRGBA(230, 153, 153, 255));
}
예제 #11
0
void DebugDraw::DrawString(const b2::Vec2& pw, const char *string, ...)
{
	b2::Vec2 ps = g_camera.ConvertWorldToScreen(pw);
	b2::float32 h = static_cast<b2::float32>(g_camera.m_height);

	char buffer[128];

	va_list arg;
	va_start(arg, string);
	std::vsprintf(buffer, string, arg);
	va_end(arg);

	AddGfxCmdText(ps.x, h - ps.y, TEXT_ALIGN_LEFT, buffer, SetRGBA(230, 153, 153, 255));
}
예제 #12
0
파일: RAS_TexVert.cpp 프로젝트: jinjoh/NOOR
RAS_TexVert::RAS_TexVert(const MT_Point3& xyz,
						 const MT_Point2& uv,
						 const MT_Point2& uv2,
						 const MT_Vector4& tangent,
						 const unsigned int rgba,
						 const MT_Vector3& normal,
						 const bool flat,
						 const unsigned int origindex)
{
	xyz.getValue(m_localxyz);
	uv.getValue(m_uv1);
	uv2.getValue(m_uv2);
	SetRGBA(rgba);
	SetNormal(normal);
	tangent.getValue(m_tangent);
	m_flag = (flat)? FLAT: 0;
	m_origindex = origindex;
	m_unit = 2;
	m_softBodyIndex = -1;
}
예제 #13
0
RAS_TexVert::RAS_TexVert(const MT_Point3& xyz,
						 const MT_Point2 uvs[MAX_UNIT],
						 const MT_Vector4& tangent,
						 const unsigned int rgba,
						 const MT_Vector3& normal,
						 const bool flat,
						 const unsigned int origindex)
{
	xyz.getValue(m_localxyz);
	SetRGBA(rgba);
	SetNormal(normal);
	tangent.getValue(m_tangent);
	m_flag = (flat)? FLAT: 0;
	m_origindex = origindex;
	m_unit = 2;
	m_softBodyIndex = -1;

	for (int i = 0; i < MAX_UNIT; ++i)
	{
		uvs[i].getValue(m_uvs[i]);
	}
}
예제 #14
0
파일: imgui.cpp 프로젝트: ZhuangChun/Box2D
bool imguiItem(const char* text, bool enabled)
{
	s_state.widgetId++;
	unsigned int id = (s_state.areaId << 16) | s_state.widgetId;

	int x = s_state.widgetX;
	int y = s_state.widgetY - BUTTON_HEIGHT;
	int w = s_state.widgetW;
	int h = BUTTON_HEIGHT;
	s_state.widgetY -= BUTTON_HEIGHT + DEFAULT_SPACING;

	bool over = enabled && inRect(x, y, w, h);
	bool res = buttonLogic(id, over);

	if (isHot(id))
		AddGfxCmdRoundedRect((float)x, (float)y, (float)w, (float)h, 2.0f, SetRGBA(255, 196, 0, isActive(id) ? 196 : 96));

	if (enabled)
		AddGfxCmdText(x + BUTTON_HEIGHT / 2, y + BUTTON_HEIGHT / 2 - TEXT_HEIGHT / 2, TEXT_ALIGN_LEFT, text, SetRGBA(255, 255, 255, 200));
	else
		AddGfxCmdText(x + BUTTON_HEIGHT / 2, y + BUTTON_HEIGHT / 2 - TEXT_HEIGHT / 2, TEXT_ALIGN_LEFT, text, SetRGBA(128, 128, 128, 200));

	return res;
}
예제 #15
0
void DmgHitColor(sRGBA *res, int timer, sParam *param)
{
	const FVector4 *dmg_col = ParamGetFVec4(param, (timer & 0x2) ? "dmg_col1" : "dmg_col2");
	SetRGBA(res, dmg_col->x, dmg_col->y, dmg_col->z, dmg_col->w);
}
예제 #16
0
파일: imgui.cpp 프로젝트: ZhuangChun/Box2D
void imguiEndScrollArea()
{
	// Disable scissoring.
	AddGfxCmdScissor(-1, -1, -1, -1);

	// Draw scroll bar
	int x = g_scrollRight + SCROLL_AREA_PADDING / 2;
	int y = g_scrollBottom;
	int w = SCROLL_AREA_PADDING * 2;
	int h = g_scrollTop - g_scrollBottom;

	int stop = g_scrollAreaTop;
	int sbot = s_state.widgetY;
	int sh = stop - sbot; // The scrollable area height.

	float barHeight = (float)h / (float)sh;

	if (barHeight < 1)
	{
		float barY = (float)(y - sbot) / (float)sh;
		if (barY < 0) barY = 0;
		if (barY > 1) barY = 1;

		// Handle scroll bar logic.
		unsigned int hid = g_scrollId;
		int hx = x;
		int hy = y + (int)(barY*h);
		int hw = w;
		int hh = (int)(barHeight*h);

		const int range = h - (hh - 1);
		bool over = inRect(hx, hy, hw, hh);
		buttonLogic(hid, over);
		if (isActive(hid))
		{
			float u = (float)(hy - y) / (float)range;
			if (s_state.wentActive)
			{
				s_state.dragY = s_state.my;
				s_state.dragOrig = u;
			}
			if (s_state.dragY != s_state.my)
			{
				u = s_state.dragOrig + (s_state.my - s_state.dragY) / (float)range;
				if (u < 0) u = 0;
				if (u > 1) u = 1;
				*g_scrollVal = (int)((1 - u) * (sh - h));
			}
		}

		// BG
		AddGfxCmdRoundedRect((float)x, (float)y, (float)w, (float)h, (float)w / 2 - 1, SetRGBA(0, 0, 0, 196));
		// Bar
		if (isActive(hid))
			AddGfxCmdRoundedRect((float)hx, (float)hy, (float)hw, (float)hh, (float)w / 2 - 1, SetRGBA(255, 196, 0, 196));
		else
			AddGfxCmdRoundedRect((float)hx, (float)hy, (float)hw, (float)hh, (float)w / 2 - 1, isHot(hid) ? SetRGBA(255, 196, 0, 96) : SetRGBA(255, 255, 255, 64));

		// Handle mouse scrolling.
		if (g_insideScrollArea) // && !anyActive())
		{
			if (s_state.scroll)
			{
				*g_scrollVal += 20 * s_state.scroll;
				if (*g_scrollVal < 0) *g_scrollVal = 0;
				if (*g_scrollVal >(sh - h)) *g_scrollVal = (sh - h);
			}
		}
	}
	s_state.insideCurrentScroll = false;
}
예제 #17
0
파일: imgui.cpp 프로젝트: ZhuangChun/Box2D
bool imguiCheck(const char* text, bool checked, bool enabled)
{
	s_state.widgetId++;
	unsigned int id = (s_state.areaId << 16) | s_state.widgetId;

	int x = s_state.widgetX;
	int y = s_state.widgetY - BUTTON_HEIGHT;
	int w = s_state.widgetW;
	int h = BUTTON_HEIGHT;
	s_state.widgetY -= BUTTON_HEIGHT + DEFAULT_SPACING;

	bool over = enabled && inRect(x, y, w, h);
	bool res = buttonLogic(id, over);

	const int cx = x + BUTTON_HEIGHT / 2 - CHECK_SIZE / 2;
	const int cy = y + BUTTON_HEIGHT / 2 - CHECK_SIZE / 2;
	AddGfxCmdRoundedRect((float)cx - 3, (float)cy - 3, (float)CHECK_SIZE + 6, (float)CHECK_SIZE + 6, 4, SetRGBA(128, 128, 128, isActive(id) ? 196 : 96));
	if (checked)
	{
		if (enabled)
			AddGfxCmdRoundedRect((float)cx, (float)cy, (float)CHECK_SIZE, (float)CHECK_SIZE, (float)CHECK_SIZE / 2 - 1, SetRGBA(255, 255, 255, isActive(id) ? 255 : 200));
		else
			AddGfxCmdRoundedRect((float)cx, (float)cy, (float)CHECK_SIZE, (float)CHECK_SIZE, (float)CHECK_SIZE / 2 - 1, SetRGBA(128, 128, 128, 200));
	}

	if (enabled)
		AddGfxCmdText(x + BUTTON_HEIGHT, y + BUTTON_HEIGHT / 2 - TEXT_HEIGHT / 2, TEXT_ALIGN_LEFT, text, isHot(id) ? SetRGBA(255, 196, 0, 255) : SetRGBA(255, 255, 255, 200));
	else
		AddGfxCmdText(x + BUTTON_HEIGHT, y + BUTTON_HEIGHT / 2 - TEXT_HEIGHT / 2, TEXT_ALIGN_LEFT, text, SetRGBA(128, 128, 128, 200));

	return res;
}
예제 #18
0
void MpColor::SetRGBA (float red, float green, float blue, float alpha)
{
  SetRGBA(int(red*65535), int(green*65535), int(blue*65535), int(alpha*255));
  // color is un-allocated now
}
예제 #19
0
파일: imgui.cpp 프로젝트: ZhuangChun/Box2D
void imguiValue(const char* text)
{
	const int x = s_state.widgetX;
	const int y = s_state.widgetY - BUTTON_HEIGHT;
	const int w = s_state.widgetW;
	s_state.widgetY -= BUTTON_HEIGHT;

	AddGfxCmdText(x + w - BUTTON_HEIGHT / 2, y + BUTTON_HEIGHT / 2 - TEXT_HEIGHT / 2, TEXT_ALIGN_RIGHT, text, SetRGBA(255, 255, 255, 200));
}
예제 #20
0
파일: imgui.cpp 프로젝트: ZhuangChun/Box2D
bool imguiSlider(const char* text, int* val, int vmin, int vmax, int vinc, bool enabled)
{
	s_state.widgetId++;
	unsigned int id = (s_state.areaId << 16) | s_state.widgetId;

	int x = s_state.widgetX;
	int y = s_state.widgetY - BUTTON_HEIGHT;
	int w = s_state.widgetW;
	int h = SLIDER_HEIGHT;
	s_state.widgetY -= SLIDER_HEIGHT + DEFAULT_SPACING;

	AddGfxCmdRoundedRect((float)x, (float)y, (float)w, (float)h, 4.0f, SetRGBA(0, 0, 0, 128));

	const int range = w - SLIDER_MARKER_WIDTH;

	float u = (*val - vmin) / float(vmax - vmin);
	if (u < 0) u = 0;
	if (u > 1) u = 1;
	int m = (int)(u * range);

	bool over = enabled && inRect(x + m, y, SLIDER_MARKER_WIDTH, SLIDER_HEIGHT);
	bool res = buttonLogic(id, over);
	bool valChanged = false;

	if (isActive(id))
	{
		if (s_state.wentActive)
		{
			s_state.dragX = s_state.mx;
			s_state.dragOrig = u;
		}
		if (s_state.dragX != s_state.mx)
		{
			u = s_state.dragOrig + (float)(s_state.mx - s_state.dragX) / (float)range;
			if (u < 0) u = 0;
			if (u > 1) u = 1;
			*val = int(vmin + u*(vmax - vmin));
			*val = int(floorf(*val / float(vinc) + 0.5f))*vinc; // Snap to vinc
			m = (int)(u * range);
			valChanged = true;
		}
	}

	if (isActive(id))
		AddGfxCmdRoundedRect((float)(x + m), (float)y, (float)SLIDER_MARKER_WIDTH, (float)SLIDER_HEIGHT, 4.0f, SetRGBA(255, 255, 255, 255));
	else
		AddGfxCmdRoundedRect((float)(x + m), (float)y, (float)SLIDER_MARKER_WIDTH, (float)SLIDER_HEIGHT, 4.0f, isHot(id) ? SetRGBA(255, 196, 0, 128) : SetRGBA(255, 255, 255, 64));

	char msg[128];
	snprintf(msg, 128, "%d", *val);

	if (enabled)
	{
		AddGfxCmdText(x + SLIDER_HEIGHT / 2, y + SLIDER_HEIGHT / 2 - TEXT_HEIGHT / 2, TEXT_ALIGN_LEFT, text, isHot(id) ? SetRGBA(255, 196, 0, 255) : SetRGBA(255, 255, 255, 200));
		AddGfxCmdText(x + w - SLIDER_HEIGHT / 2, y + SLIDER_HEIGHT / 2 - TEXT_HEIGHT / 2, TEXT_ALIGN_RIGHT, msg, isHot(id) ? SetRGBA(255, 196, 0, 255) : SetRGBA(255, 255, 255, 200));
	}
	else
	{
		AddGfxCmdText(x + SLIDER_HEIGHT / 2, y + SLIDER_HEIGHT / 2 - TEXT_HEIGHT / 2, TEXT_ALIGN_LEFT, text, SetRGBA(128, 128, 128, 200));
		AddGfxCmdText(x + w - SLIDER_HEIGHT / 2, y + SLIDER_HEIGHT / 2 - TEXT_HEIGHT / 2, TEXT_ALIGN_RIGHT, msg, SetRGBA(128, 128, 128, 200));
	}

	return res || valChanged;
}
예제 #21
0
ON_Color::ON_Color(int r, int g, int b, int a) : m_color(0) 
{
  SetRGBA(r,g,b,a);
}
예제 #22
0
void ON_Color::SetRGB(int r,int g,int b) // 0 to 255
{
  SetRGBA(r,g,b,0);
}
예제 #23
0
파일: nn_bullet.c 프로젝트: usagi/TieGunner
static int objProc(sOBJ *obj, sParam *param, int msg, int lParam, int rParam)
{
	int res = 0;

	ObjVar *var = (ObjVar *)ObjGetVar(obj, sizeof(ObjVar));
	switch(msg)
	{
	case MSG_CREATE:
		{
			var->level = lParam;
			var->target_flag = (u_int)rParam;
			var->param = (sParam *)StkRefFrameP(0);
			var->pos = *(FVector2 *)StkRefFrameP(1);
			var->vct = *(FVector2 *)StkRefFrameP(2);
			var->dir = StkRefFrameF(3);
			float powofs = StkRefFrameF(4);

			var->radius = ParamGetReal(param, "radius");
			var->speed = ParamGetReal(param, "speed");
			var->power = PowerConvertInterValue(ParamGetReal(param, "power") * powofs);
			FVector4 *col;
			col = ParamGetFVec4(param, "col1");
			SetRGBA(&var->col1, col->x, col->y, col->z, col->w);
			col = ParamGetFVec4(param, "col2");
			SetRGBA(&var->col2, col->x, col->y, col->z, col->w);
			var->disp_size = ParamGetFVec2(param, "disp_size");
			

			FVector2 vct; 
			MathCalcVector(&vct, var->dir, var->speed);
			var->vct.x += vct.x;
			var->vct.y += vct.y;

			ObjSetPos(obj, var->pos.x, var->pos.y);
			ObjSetDir(obj, var->dir);
			ObjSetVct(obj, var->vct.x, var->vct.y);
		}
		break;

	case MSG_KILL:
		{
		}
		break;

	case MSG_STEP:
		{
#if 0
			GameFieldRange(&var->pos);
#endif

			var->pos.x += var->vct.x;
			var->pos.y += var->vct.y;
			
			ObjSetPos(obj, var->pos.x, var->pos.y);
			ObjSetDir(obj, var->dir);
			ObjSetVct(obj, var->vct.x, var->vct.y);

			res = FieldClip(&var->pos, 20.0f);
			if(res)
			{
				ObjKillReq(obj);
			}
			else
			{
				/* TODO:非常に重い処理なので解決策を考える */
				BOOL kill = sendDamage(obj, var->target_flag, &var->pos, &var->vct, var->radius, var->power);
				if(kill)
				{
					ObjKillReq(obj);
				}
			}
		}
		break;

	case MSG_DRAW:
		{
			sGRPOBJ *grp;
			grp = GRPOBJ_FILLCIRCLE(PRIO_SHOT);
			GrpSetPos(grp, var->disp_x, var->disp_y);
			GrpSetRot(grp, var->dir);
			GrpSetRGBA(grp, var->col1.red, var->col1.green, var->col1.blue, var->col1.alpha);
			GrpSetSize(grp, var->disp_size->x, var->disp_size->x);
			GrpSetLineNum(grp, 8);
			GrpSetSmooth(grp, TRUE);

			grp = GRPOBJ_FILLCIRCLE(PRIO_SHOT);
			GrpSetPos(grp, var->disp_x, var->disp_y);
			GrpSetRot(grp, var->dir);
			GrpSetRGBA(grp, var->col2.red, var->col2.green, var->col2.blue, var->col2.alpha);
			GrpSetSize(grp, var->disp_size->y, var->disp_size->y);
			GrpSetLineNum(grp, 6);
			GrpSetSmooth(grp, TRUE);
			
#ifdef DEBUG
			if(isDispDebugInfo())
			{
				sGRPOBJ *grp = GRPOBJ_CIRCLE(PRIO_DEBUG_PRINT);
				GrpSetPos(grp, var->disp_x, var->disp_y);
				GrpSetSize(grp, var->radius, var->radius);
				GrpSetLineNum(grp, 12);
				GrpSetRGBA(grp, 1.0f, 1.0f, 0.0f, 1.0f);
				GrpSetDrawSize(grp, 1.0f);
			}
#endif
		}
		break;

	case MSG_GAME_CAMERA:
		{
			FVector2 *pos = (FVector2 *)StkRefFrameP(0);
			var->disp_x = var->pos.x - pos->x;
			var->disp_y = var->pos.y - pos->y;
		}
		break;
	}

	return res;
}