diff options
author | madmaxoft <github@xoft.cz> | 2014-01-12 10:04:16 +0100 |
---|---|---|
committer | madmaxoft <github@xoft.cz> | 2014-01-12 10:04:16 +0100 |
commit | 180b9b90993870532a8daa2ee6498005b6c3bf49 (patch) | |
tree | dac846b760b6f5fd294fbd771975dd55b0856c0d /Tools | |
parent | Fixed Linux configuration. (diff) | |
parent | Disabled a useless MSVC warning in Bindings.cpp. (diff) | |
download | cuberite-180b9b90993870532a8daa2ee6498005b6c3bf49.tar cuberite-180b9b90993870532a8daa2ee6498005b6c3bf49.tar.gz cuberite-180b9b90993870532a8daa2ee6498005b6c3bf49.tar.bz2 cuberite-180b9b90993870532a8daa2ee6498005b6c3bf49.tar.lz cuberite-180b9b90993870532a8daa2ee6498005b6c3bf49.tar.xz cuberite-180b9b90993870532a8daa2ee6498005b6c3bf49.tar.zst cuberite-180b9b90993870532a8daa2ee6498005b6c3bf49.zip |
Diffstat (limited to 'Tools')
-rw-r--r-- | Tools/BiomeVisualiser/.gitignore | 1 | ||||
-rw-r--r-- | Tools/BiomeVisualiser/BiomeRenderer.cpp | 12 | ||||
-rw-r--r-- | Tools/BiomeVisualiser/BiomeRenderer.h | 5 | ||||
-rw-r--r-- | Tools/BiomeVisualiser/BiomeViewWnd.cpp | 64 | ||||
-rw-r--r-- | Tools/BiomeVisualiser/BiomeViewWnd.h | 4 | ||||
-rw-r--r-- | Tools/BiomeVisualiser/BiomeVisualiser.vcproj | 10 | ||||
-rw-r--r-- | Tools/ProtoProxy/Connection.cpp | 4 |
7 files changed, 78 insertions, 22 deletions
diff --git a/Tools/BiomeVisualiser/.gitignore b/Tools/BiomeVisualiser/.gitignore index b4e15dc3c..cfbc9164c 100644 --- a/Tools/BiomeVisualiser/.gitignore +++ b/Tools/BiomeVisualiser/.gitignore @@ -1,3 +1,4 @@ Debug/ logs/ Release/ +Release profiled/ diff --git a/Tools/BiomeVisualiser/BiomeRenderer.cpp b/Tools/BiomeVisualiser/BiomeRenderer.cpp index 758eb4b48..569128a12 100644 --- a/Tools/BiomeVisualiser/BiomeRenderer.cpp +++ b/Tools/BiomeVisualiser/BiomeRenderer.cpp @@ -40,10 +40,10 @@ bool cBiomeRenderer::Render(cPixmap & a_Pixmap) int Hei = a_Pixmap.GetHeight(); // Hint the approximate view area to the biome source so that it can adjust its caches: - int MinBlockX = ( - m_OriginX) / m_Zoom; - int MaxBlockX = (Wid - m_OriginX) / m_Zoom; - int MinBlockZ = ( - m_OriginY) / m_Zoom; - int MaxBlockZ = (Hei - m_OriginY) / m_Zoom; + int MinBlockX = ( - m_OriginX) * m_Zoom; + int MaxBlockX = (Wid - m_OriginX) * m_Zoom; + int MinBlockZ = ( - m_OriginY) * m_Zoom; + int MaxBlockZ = (Hei - m_OriginY) * m_Zoom; m_Cache.HintViewArea(MinBlockX / 16 - 1, MaxBlockX / 16 + 1, MinBlockZ / 16 - 1, MaxBlockZ / 16 + 1); // Hold one current chunk of biome data: @@ -55,12 +55,12 @@ bool cBiomeRenderer::Render(cPixmap & a_Pixmap) for (int y = 0; y < Hei; y++) { - int BlockZ = (y - m_OriginY) / m_Zoom; + int BlockZ = (y - m_OriginY) * m_Zoom; int ChunkZ = (BlockZ >= 0) ? (BlockZ / 16) : ((BlockZ + 1) / 16 - 1); int RelZ = BlockZ - ChunkZ * 16; for (int x = 0; x < Wid; x++) { - int BlockX = (x - m_OriginX) / m_Zoom; + int BlockX = (x - m_OriginX) * m_Zoom; int ChunkX = (BlockX >= 0) ? (BlockX / 16) : ((BlockX + 1) / 16 - 1); int RelX = BlockX - ChunkX * 16; if ((ChunkZ != CurChunkZ) || (ChunkX != CurChunkX)) diff --git a/Tools/BiomeVisualiser/BiomeRenderer.h b/Tools/BiomeVisualiser/BiomeRenderer.h index 2590e0406..752b61811 100644 --- a/Tools/BiomeVisualiser/BiomeRenderer.h +++ b/Tools/BiomeVisualiser/BiomeRenderer.h @@ -37,6 +37,11 @@ public: void MoveViewBy(int a_OffsX, int a_OffsY); + void SetZoom(int a_NewZoom) + { + m_Zoom = a_NewZoom; + } + protected: cBiomeCache m_Cache; diff --git a/Tools/BiomeVisualiser/BiomeViewWnd.cpp b/Tools/BiomeVisualiser/BiomeViewWnd.cpp index 5c1240bc7..7fb61c062 100644 --- a/Tools/BiomeVisualiser/BiomeViewWnd.cpp +++ b/Tools/BiomeVisualiser/BiomeViewWnd.cpp @@ -67,17 +67,41 @@ void cBiomeViewWnd::InitBiomeView(void) +void cBiomeViewWnd::SetZoom(int a_NewZoom) +{ + m_Renderer.SetZoom(a_NewZoom); + Redraw(); +} + + + + + +void cBiomeViewWnd::Redraw(void) +{ + if (m_Renderer.Render(m_Pixmap)) + { + SetTimer(m_Wnd, TIMER_RERENDER, 200, NULL); + } + InvalidateRect(m_Wnd, NULL, FALSE); +} + + + + + LRESULT cBiomeViewWnd::WndProc(HWND a_Wnd, UINT a_Msg, WPARAM wParam, LPARAM lParam) { switch (a_Msg) { - case WM_CLOSE: return OnClose(); - case WM_COMMAND: return OnCommand(wParam, lParam); + case WM_CHAR: return OnChar (wParam, lParam); + case WM_CLOSE: return OnClose (); + case WM_COMMAND: return OnCommand (wParam, lParam); case WM_LBUTTONDOWN: return OnLButtonDown(wParam, lParam); case WM_LBUTTONUP: return OnLButtonUp (wParam, lParam); case WM_MOUSEMOVE: return OnMouseMove (wParam, lParam); - case WM_PAINT: return OnPaint(); - case WM_TIMER: return OnTimer(wParam); + case WM_PAINT: return OnPaint (); + case WM_TIMER: return OnTimer (wParam); } return ::DefWindowProc(a_Wnd, a_Msg, wParam, lParam); } @@ -86,6 +110,32 @@ LRESULT cBiomeViewWnd::WndProc(HWND a_Wnd, UINT a_Msg, WPARAM wParam, LPARAM lPa +LRESULT cBiomeViewWnd::OnChar(WPARAM wParam, LPARAM lParam) +{ + switch (wParam) + { + case '1': SetZoom(1); break; + case '2': SetZoom(2); break; + case '3': SetZoom(3); break; + case '4': SetZoom(4); break; + case '5': SetZoom(5); break; + case '6': SetZoom(6); break; + case '7': SetZoom(7); break; + case '8': SetZoom(8); break; + case 27: + { + // Esc pressed, exit + PostQuitMessage(0); + break; + } + } + return 0; +} + + + + + LRESULT cBiomeViewWnd::OnClose(void) { PostQuitMessage(0); @@ -126,12 +176,8 @@ LRESULT cBiomeViewWnd::OnMouseMove(WPARAM wParam, LPARAM lParam) POINT pnt; GetCursorPos(&pnt); m_Renderer.MoveViewBy(pnt.x - m_MouseDown.x, pnt.y - m_MouseDown.y); - if (m_Renderer.Render(m_Pixmap)) - { - SetTimer(m_Wnd, TIMER_RERENDER, 200, NULL); - } m_MouseDown = pnt; - InvalidateRect(m_Wnd, NULL, FALSE); + Redraw(); return 0; } diff --git a/Tools/BiomeVisualiser/BiomeViewWnd.h b/Tools/BiomeVisualiser/BiomeViewWnd.h index e3f70c7e6..70c5e38f2 100644 --- a/Tools/BiomeVisualiser/BiomeViewWnd.h +++ b/Tools/BiomeVisualiser/BiomeViewWnd.h @@ -48,9 +48,13 @@ protected: void InitBiomeView(void); + void SetZoom(int a_NewZoom); + void Redraw(void); + LRESULT WndProc(HWND a_Wnd, UINT a_Msg, WPARAM wParam, LPARAM lParam); // Message handlers: + LRESULT OnChar (WPARAM wParam, LPARAM lParam); LRESULT OnClose (void); LRESULT OnCommand (WPARAM wParam, LPARAM lParam); LRESULT OnLButtonDown(WPARAM wParam, LPARAM lParam); diff --git a/Tools/BiomeVisualiser/BiomeVisualiser.vcproj b/Tools/BiomeVisualiser/BiomeVisualiser.vcproj index e42870b13..368657938 100644 --- a/Tools/BiomeVisualiser/BiomeVisualiser.vcproj +++ b/Tools/BiomeVisualiser/BiomeVisualiser.vcproj @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="windows-1250"?> <VisualStudioProject ProjectType="Visual C++" - Version="9,00" + Version="9.00" Name="BiomeVisualiser" ProjectGUID="{6DF3D88B-AD47-45B6-B831-1BDE74F86B5C}" RootNamespace="BiomeVisualiser" @@ -273,6 +273,10 @@ > </File> <File + RelativePath=".\BiomeColors.h" + > + </File> + <File RelativePath=".\BiomeRenderer.cpp" > </File> @@ -501,10 +505,6 @@ </Filter> </Filter> </Filter> - <File - RelativePath=".\BiomeColors.h" - > - </File> </Files> <Globals> </Globals> diff --git a/Tools/ProtoProxy/Connection.cpp b/Tools/ProtoProxy/Connection.cpp index 10f2b4073..f38ea02ed 100644 --- a/Tools/ProtoProxy/Connection.cpp +++ b/Tools/ProtoProxy/Connection.cpp @@ -2390,12 +2390,12 @@ bool cConnection::HandleServerStatusResponse(void) { Response.assign(Response.substr(0, idx + sizeof(DescSearch) - 1) + "ProtoProxy: " + Response.substr(idx + sizeof(DescSearch) - 1)); } - cByteBuffer Packet(1000); + cByteBuffer Packet(Response.size() + 50); Packet.WriteVarInt(0); // Packet type - status response Packet.WriteVarUTF8String(Response); AString Pkt; Packet.ReadAll(Pkt); - cByteBuffer ToClient(1000); + cByteBuffer ToClient(Response.size() + 50); ToClient.WriteVarUTF8String(Pkt); CLIENTSEND(ToClient); return true; |