int Menu_AppSelect::DoModal() { // TEST SWF BEGIN #if 0 class CTestMenu : public UIMenu { public: CTestMenu(const char * movieName) : UIMenu(movieName) {} virtual ~CTestMenu() {}; virtual bool Initialize() {return true;} virtual int Update() { r3dProcessWindowMessages(); r3dMouse::Show(); r3dStartFrame(); r3dRenderer->StartRender(1); r3dRenderer->StartFrame(); r3dRenderer->SetRenderingMode(R3D_BLEND_ALPHA | R3D_BLEND_NZ); ClearFullScreen_Menu(); gfxMovie.Update(); gfxMovie.Draw(); r3dRenderer->Flush(); r3dRenderer->EndFrame(); r3dRenderer->EndRender( true ); r3dEndFrame(); return 0; }; }; CTestMenu* menu = new CTestMenu("data/menu/HUD_OutOfBattleZone.swf"); menu->Load(); int res = 0; if(menu->Initialize()) { while(res == 0) { res = menu->Update(); } } menu->Unload(); SAFE_DELETE(menu); // TEST SWF END #endif AppSelectMode = 100; Desktop().SetViewSize( r3dRenderer->ScreenW, r3dRenderer->ScreenH ); while(1) { if(g_bExit) return 0; r3dStartFrame(); mUpdate(); imgui_Update(); int ret = 1; mDrawStart(); ClearFullScreen_Menu(); r3dRenderer->SetRenderingMode(R3D_BLEND_ALPHA | R3D_BLEND_NZ); r3dSetFiltering( R3D_POINT ); r3dRenderer->SetMipMapBias(-6.0f,-1); switch (AppSelectMode) { case 100: { const static char *BNames1[] = {"Update DB", "Game (Public Server)", "Game (DEV Server)" }; for (int i=0;i<R3D_ARRAYSIZE(BNames1);i++) if (imgui_Button(r3dRenderer->ScreenW/2-(210*R3D_ARRAYSIZE(BNames1))/2+210*i, r3dRenderer->ScreenH/2 - 30,200, 30,BNames1[i], 0)) released_id = bUpdateDB+i; const static char* BNames[] = {"Level Editor", "Particle Editor", "Physics Editor", "Character Editor" }; for (int i=0;i<R3D_ARRAYSIZE(BNames);i++) if (imgui_Button(r3dRenderer->ScreenW/2-(210*R3D_ARRAYSIZE(BNames))/2+210*i, r3dRenderer->ScreenH/2 + 30,200, 30,BNames[i], 0)) released_id = bStartLevelEditor+i; } break; } r3dRenderer->pd3ddev->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE); r3dRenderer->SetRenderingMode(R3D_BLEND_NOALPHA | R3D_BLEND_NZ); mDrawEnd(); r3dEndFrame(); switch(released_id) { case -1: break; default: return released_id; }; } return 0; }
bool Ctrl::ProcessEvent(const String& event) { LLOG("Processing event " << event); CParser p(event); try { if(p.Id("I")) SystemDraw::ResetI(); else if(p.Id("R")) { DesktopSize = ReadPoint(p); Desktop().SetRect(0, 0, DesktopSize.cx, DesktopSize.cy); } if(p.Id("M")) { Point pt = ReadPoint(p); int64 tm = p.ReadInt64(); DoMouseFB(MOUSEMOVE, pt, 0, p); } else if(p.Id("W")) { double w = p.ReadDouble(); Point pt = ReadPoint(p); int64 tm = p.ReadInt64(); DoMouseFB(MOUSEWHEEL, pt, w < 0 ? 120 : -120, p); } else if(p.Id("O")) { mouseLeft = mouseMiddle = mouseRight = false; mouseDownTime = 0; } else if(p.Id("D")) { DoMouseButton(DOWN, p); } else if(p.Id("U")) { DoMouseButton(UP, p); } else if(p.Id("K")) { int code = p.ReadInt(); int which = p.ReadInt(); int count = 1; for(;;) { if(event_queue.GetCount() && event_queue[0] == event) { // Chrome autorepeat event_queue.DropHead(); count++; } else if(event_queue.GetCount() >= 2 && *event_queue[0] == 'C' && event_queue[1] == event) { // Firefox autorepeat String h = event_queue[0]; event_queue.DropHead(); event_queue.DropHead(); event_queue.AddHead(h); count++; } else break; } ReadKeyMods(p); DoKeyFB(fbKEYtoK(which), count); } else if(p.Id("k")) { int code = p.ReadInt(); int which = p.ReadInt(); ReadKeyMods(p); DoKeyFB(K_KEYUP|fbKEYtoK(which), 1); } else if(p.Id("C")) { int code = p.ReadInt(); int which = p.ReadInt(); ReadKeyMods(p); int count = 1; while(event_queue.GetCount() && event_queue[0] == event) { // 'K's are not there anymore event_queue.DropHead(); count++; } if(which && !keyAlt && !keyCtrl && findarg(which, 9, 0xd) < 0) DoKeyFB(which, 1); } } catch(CParser::Error) {} return true; }
void UICurveEditor::DrawBezier( float in_x, float in_y, float in_w, float in_h, const char *Title, r3dBezierGradient* edit_val, float* pVertScale, float in_minVal, float in_maxVal, int x_steps /*= 10*/, int y_steps /*= 10*/, int x_precision /*= 2*/, int y_precision /*= 2*/, bool bUseDesktop ) { if ( bUseDesktop ) { if ( ! Desktop().IsWindowVisible( in_x, in_y, in_x + in_w, in_y + in_h ) ) return; in_x -= Desktop().GetX(); in_y -= Desktop().GetY(); } const int x_dels = x_steps; const int y_dels = y_steps; static const float off_field = 30; static const float off_header = 20; static const r3dColor clr_bg(50, 50, 50); static const r3dColor clr_hdr(80, 120, 80); static const r3dColor clr_fld(30, 30, 30); static const r3dColor clr_line(100, 100, 100); static const r3dColor clr_selline(200, 200, 200); float ui_x = in_x; float ui_y = in_y; float ui_w = in_w; float ui_h = in_h - 8; // field coords fx = ui_x + off_field; fw = ui_w - off_field - off_field; fy = ui_y + off_header; fh = ui_h - off_field - off_header; r3dBezierGradient& grad = *edit_val; if( pVertScale ) { r3d_assert( "Copy me from UICurveEditor::DrawIM!!" ); } else { vertScale = 1.f ; } if(in_minVal > -9999) { minMaxLocked = true; minVal = in_minVal; maxVal = in_maxVal; // apply min/max limits float min = R3D_MIN(minVal, maxVal); float max = R3D_MAX(minVal, maxVal); for(int i=0; i<grad.NumValues; i++) { r3dBezierGradient::val_s& gv = grad.Values[i]; gv.val[0] = R3D_CLAMP(gv.val[0], min, max); } } else { minMaxLocked = false; // unrestricted mode - detect min/max minVal = 9999; maxVal = -9999; for(int i=0; i<grad.NumValues; i++) { r3dBezierGradient::val_s& gv = grad.Values[i]; if(minVal > gv.val[0]) minVal = gv.val[0]; if(maxVal < gv.val[0]) maxVal = gv.val[0]; } minVal -= 1.0f; maxVal += 1.0f; if(imgui_val == edit_val) { // do not change min/val while dragging! minVal = dragSavedMin; maxVal = dragSavedMax; } } // draw backgoround r3dDrawBox2D(ui_x, ui_y, ui_w, in_h, clr_bg); r3dDrawBox2D(fx, fy, fw, fh, clr_fld); r3dDrawBox2D(ui_x, ui_y, ui_w, off_header-2, clr_hdr); MenuFont_Editor->PrintF(ui_x+5, ui_y+2, r3dColor(255,255,255), Title); x_precision = R3D_MIN( R3D_MAX( x_precision, 0 ), 9 ); y_precision = R3D_MIN( R3D_MAX( y_precision, 0 ), 9 ); char num_fmt[] = "%.0f"; const int fmt_precision_pos = 2; // draw x lines - from 0.0 to 1.0 { float x = fx; float y = fy; float dx = fw / x_dels; num_fmt[fmt_precision_pos] = '0' + x_precision; for(int i=0; i<=x_dels; i++) { r3dDrawVLine(x, y, ui_h - off_header, clr_line); MenuFont_Editor->PrintF(x+2, y+fh+2, r3dColor::white, num_fmt, float(i) / x_dels); x += dx; } } // draw y lines - from minVal to maxVal { float x = float(ui_x); float y = fy; float dy = fh / y_dels; float val = maxVal; float vd = (minVal - maxVal) / y_dels; num_fmt[fmt_precision_pos] = '0' + y_precision; for(int i=0; i<=y_dels; i++) { r3dDrawHLine(x, y, ui_w, clr_line); MenuFont_Editor->PrintF(x, y, r3dColor::white, num_fmt, val); y += dy; val += vd; } } DrawBezierCurve(*edit_val ); DrawBezierPoints(*edit_val, imgui_val == NULL); if(imgui_disabled) return; if(imgui_val && imgui_val != edit_val) return; // draw mouseover lines && current coordinate/value if(!g_imgui_InDrag && imgui_mx >= fx && imgui_mx <= fx+fw && imgui_my >= fy && imgui_my <= fy+fh && (imgui_val == NULL || imgui_val == edit_val)) { r3dDrawHLine(fx, imgui_my, fw, clr_selline); r3dDrawVLine(imgui_mx, fy, fh, clr_selline); if(selectedPnt == -1) { float vx, vy; CalcFromCoord(imgui_mx, imgui_my, vx, vy); MenuFont_Editor->PrintF(imgui_mx+2, imgui_my+2, r3dColor::white, "----Time:%.2f Val:%.4f", vx, vy); } } // if we snapped on point - print it's coordinate/value if(selectedPnt != -1) { const r3dBezierGradient::val_s& gv = grad.Values[selectedPnt]; float x, y; CalcFromValue(gv, x, y); MenuFont_Editor->PrintF(x+2, y+2, r3dColor::white, "****Time:%.2f Val:%.4f", gv.time, gv.val[0]); MenuFont_Editor->PrintF(ui_x+0, ui_y-2, r3dColor::white, "[%.2f]:%.4f", gv.time, gv.val[0]); } bool act1 = !g_imgui_InDrag && imgui_lbp && !Keyboard->IsPressed(kbsLeftControl); bool act2 = !g_imgui_InDrag && imgui_lbp && Keyboard->IsPressed(kbsLeftControl); // // point dragging // if(imgui_val == NULL && selectedPnt != -1 && imgui_val != this && act1) { // enable point dragging imgui_val = edit_val; draggingPnt = selectedPnt; dragSavedMin= minVal; dragSavedMax= maxVal; } if(imgui_val == edit_val) { assert(draggingPnt != -1); // update dragging point float vx, vy; CalcFromCoord(imgui_mx, imgui_my, vx, vy); r3dBezierGradient::val_s& gv = grad.Values[draggingPnt]; if(gv.time < 0.001f || gv.time > 0.999f) { // do not edit value for border params gv.val[0] = vy; } else { gv.time = R3D_CLAMP(vx, 0.01f, 0.98f); gv.val[0] = vy; grad.ResortAfterChange(&selectedPnt); } if(imgui_lbr) { imgui_val = NULL; draggingPnt = -1; } return; } // // point adding/removing // if(imgui_mx >= fx && imgui_mx <= fx+fw && imgui_my >= fy && imgui_my <= fy+fh) { assert(imgui_val == NULL); if(selectedPnt != -1 && act2) { // remove selected point (only not border ones) if(selectedPnt != 0 && selectedPnt != grad.NumValues-1) { grad.NumValues--; memmove(&grad.Values[selectedPnt], &grad.Values[selectedPnt+1], sizeof(grad.Values[0]) * (grad.NumValues - selectedPnt)); grad.UpdateControlPoints (); selectedPnt = -1; return; } } if(selectedPnt == -1 && act1) { // add new control point and lock it for dragging float vx, vy; CalcFromCoord(imgui_mx, imgui_my, vx, vy); draggingPnt = grad.AddValue(vx, vy); dragSavedMin= minVal; dragSavedMax= maxVal; imgui_val = edit_val; return; } } return; }
Desktop StateServiceNull::getActiveDesktop() { return Desktop(); }