| 2338 | } |
| 2339 | |
| 2340 | void 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 | { |
nothing calls this directly
no test coverage detected