MCPcopy Create free account
hub / github.com/ddnet/ddnet / DoMapEditor

Method DoMapEditor

src/game/editor/editor.cpp:2340–2932  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2338}
2339
2340void CEditor::DoMapEditor(CUIRect View)
2341{
2342 // render all good stuff
2343 if(!m_ShowPicker)
2344 {
2345 MapView()->RenderEditorMap();
2346 }
2347 else
2348 {
2349 // fix aspect ratio of the image in the picker
2350 float Max = minimum(View.w, View.h);
2351 View.w = View.h = Max;
2352 }
2353
2354 const bool Inside = Ui()->MouseInside(&View);
2355
2356 // fetch mouse position
2357 float wx = Ui()->MouseWorldX();
2358 float wy = Ui()->MouseWorldY();
2359 float mx = Ui()->MouseX();
2360 float my = Ui()->MouseY();
2361
2362 static float s_StartWx = 0;
2363 static float s_StartWy = 0;
2364
2365 enum
2366 {
2367 OP_NONE = 0,
2368 OP_BRUSH_GRAB,
2369 OP_BRUSH_DRAW,
2370 OP_BRUSH_PAINT,
2371 OP_PAN_WORLD,
2372 OP_PAN_EDITOR,
2373 };
2374
2375 // remap the screen so it can display the whole tileset
2376 if(m_ShowPicker)
2377 {
2378 CUIRect Screen = *Ui()->Screen();
2379 float Size = 32.0f * 16.0f;
2380 float w = Size * (Screen.w / View.w);
2381 float h = Size * (Screen.h / View.h);
2382 float x = -(View.x / Screen.w) * w;
2383 float y = -(View.y / Screen.h) * h;
2384 wx = x + w * mx / Screen.w;
2385 wy = y + h * my / Screen.h;
2386 std::shared_ptr<CLayerTiles> pTileLayer = std::static_pointer_cast<CLayerTiles>(Map()->SelectedLayerType(0, LAYERTYPE_TILES));
2387 if(pTileLayer)
2388 {
2389 Graphics()->MapScreen(x, y, x + w, y + h);
2390 m_pTilesetPicker->m_Image = pTileLayer->m_Image;
2391 if(m_BrushColorEnabled)
2392 {
2393 m_pTilesetPicker->m_Color = pTileLayer->m_Color;
2394 m_pTilesetPicker->m_Color.a = 255;
2395 }
2396 else
2397 {

Callers

nothing calls this directly

Calls 15

MapViewFunction · 0.85
UiFunction · 0.85
MapFunction · 0.85
GraphicsFunction · 0.85
f2fxFunction · 0.85
InputFunction · 0.85
fx2fFunction · 0.85
distanceFunction · 0.85
str_formatFunction · 0.85
RenderEditorMapMethod · 0.80
MouseInsideMethod · 0.80
MouseWorldXMethod · 0.80

Tested by

no test coverage detected