From 2b5c532589b225431ad1dc02212e274c25493a17 Mon Sep 17 00:00:00 2001 From: Shereef Marzouk Date: Tue, 2 Aug 2011 12:14:49 +0200 Subject: converted white spaces to tabs --- src/game/editor/editor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/game/editor/editor.cpp') diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index 500e600b..5c897953 100644 --- a/src/game/editor/editor.cpp +++ b/src/game/editor/editor.cpp @@ -957,7 +957,7 @@ void CEditor::DoToolbar(CUIRect ToolBar) if(DoButton_Editor(&s_BorderBut, "Border", pT?0:-1, &Button, 0, "Adds border tiles")) { if(pT) - DoMapBorder(); + DoMapBorder(); } } -- cgit 1.4.1 From b7605dd0b531fec5e70635b5cbaf36cb29e96730 Mon Sep 17 00:00:00 2001 From: oy Date: Thu, 4 Aug 2011 18:41:41 +0200 Subject: reset quad point selection when activating a different quad. Closes #819 --- src/game/editor/editor.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/game/editor/editor.cpp') diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index 5c897953..54f09bca 100644 --- a/src/game/editor/editor.cpp +++ b/src/game/editor/editor.cpp @@ -1163,6 +1163,8 @@ void CEditor::DoQuad(CQuad *q, int Index) s_Operation = OP_MOVE_ALL; UI()->SetActiveItem(pID); + if(m_SelectedQuad != Index) + m_SelectedPoints = 0; m_SelectedQuad = Index; s_LastWx = wx; s_LastWy = wy; @@ -1170,7 +1172,9 @@ void CEditor::DoQuad(CQuad *q, int Index) if(UI()->MouseButton(1)) { - m_SelectedQuad = Index; + if(m_SelectedQuad != Index) + m_SelectedPoints = 0; + m_SelectedQuad = Index; s_Operation = OP_CONTEXT_MENU; UI()->SetActiveItem(pID); } -- cgit 1.4.1 From fee2c2c45207df99d6908059ec06b0d8b5ec272c Mon Sep 17 00:00:00 2001 From: oy Date: Thu, 4 Aug 2011 18:47:57 +0200 Subject: fixed an overlapping in the editor. Closes #794 --- src/game/editor/editor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/game/editor/editor.cpp') diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index 54f09bca..889cafdd 100644 --- a/src/game/editor/editor.cpp +++ b/src/game/editor/editor.cpp @@ -2056,7 +2056,7 @@ void CEditor::RenderLayers(CUIRect ToolBox, CUIRect ToolBar, CUIRect View) static int s_GroupPopupId = 0; if(Result == 2) - UiInvokePopupMenu(&s_GroupPopupId, 0, UI()->MouseX(), UI()->MouseY(), 120, 220, PopupGroup); + UiInvokePopupMenu(&s_GroupPopupId, 0, UI()->MouseX(), UI()->MouseY(), 145, 220, PopupGroup); if(m_Map.m_lGroups[g]->m_lLayers.size() && Input()->MouseDoubleClick()) m_Map.m_lGroups[g]->m_Collapse ^= 1; -- cgit 1.4.1 From e5395f00b39b6a7e1beca405c33c6155e83d3b5a Mon Sep 17 00:00:00 2001 From: oy Date: Thu, 4 Aug 2011 23:34:29 +0200 Subject: fixed that activating a quad point doesn't align it on the grid and made moving the pivot use the grid. Closes#792 --- src/game/editor/editor.cpp | 105 +++++++++++++++++++++++++++------------------ 1 file changed, 64 insertions(+), 41 deletions(-) (limited to 'src/game/editor/editor.cpp') diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index 889cafdd..4dfda743 100644 --- a/src/game/editor/editor.cpp +++ b/src/game/editor/editor.cpp @@ -1056,58 +1056,82 @@ void CEditor::DoQuad(CQuad *q, int Index) if(UI()->ActiveItem() == pID) { - // check if we only should move pivot - if(s_Operation == OP_MOVE_PIVOT) + if(m_MouseDeltaWx*m_MouseDeltaWx+m_MouseDeltaWy*m_MouseDeltaWy > 0.5f) { - q->m_aPoints[4].x += f2fx(wx-s_LastWx); - q->m_aPoints[4].y += f2fx(wy-s_LastWy); - } - else if(s_Operation == OP_MOVE_ALL) - { - // move all points including pivot - if(m_GridActive) + // check if we only should move pivot + if(s_Operation == OP_MOVE_PIVOT) { - int LineDistance = GetLineDistance(); + if(m_GridActive) + { + int LineDistance = GetLineDistance(); - float x = 0.0f; - float y = 0.0f; - if(wx >= 0) - x = (int)((wx+(LineDistance/2)*m_GridFactor)/(LineDistance*m_GridFactor)) * (LineDistance*m_GridFactor); - else - x = (int)((wx-(LineDistance/2)*m_GridFactor)/(LineDistance*m_GridFactor)) * (LineDistance*m_GridFactor); - if(wy >= 0) - y = (int)((wy+(LineDistance/2)*m_GridFactor)/(LineDistance*m_GridFactor)) * (LineDistance*m_GridFactor); + float x = 0.0f; + float y = 0.0f; + if(wx >= 0) + x = (int)((wx+(LineDistance/2)*m_GridFactor)/(LineDistance*m_GridFactor)) * (LineDistance*m_GridFactor); + else + x = (int)((wx-(LineDistance/2)*m_GridFactor)/(LineDistance*m_GridFactor)) * (LineDistance*m_GridFactor); + if(wy >= 0) + y = (int)((wy+(LineDistance/2)*m_GridFactor)/(LineDistance*m_GridFactor)) * (LineDistance*m_GridFactor); + else + y = (int)((wy-(LineDistance/2)*m_GridFactor)/(LineDistance*m_GridFactor)) * (LineDistance*m_GridFactor); + + q->m_aPoints[4].x = f2fx(x); + q->m_aPoints[4].y = f2fx(y); + } else - y = (int)((wy-(LineDistance/2)*m_GridFactor)/(LineDistance*m_GridFactor)) * (LineDistance*m_GridFactor); - - int OldX = q->m_aPoints[4].x; - int OldY = q->m_aPoints[4].y; - q->m_aPoints[4].x = f2fx(x); - q->m_aPoints[4].y = f2fx(y); - int DiffX = q->m_aPoints[4].x - OldX; - int DiffY = q->m_aPoints[4].y - OldY; - - for(int v = 0; v < 4; v++) { - q->m_aPoints[v].x += DiffX; - q->m_aPoints[v].y += DiffY; + q->m_aPoints[4].x += f2fx(wx-s_LastWx); + q->m_aPoints[4].y += f2fx(wy-s_LastWy); } } - else + else if(s_Operation == OP_MOVE_ALL) { - for(int v = 0; v < 5; v++) + // move all points including pivot + if(m_GridActive) + { + int LineDistance = GetLineDistance(); + + float x = 0.0f; + float y = 0.0f; + if(wx >= 0) + x = (int)((wx+(LineDistance/2)*m_GridFactor)/(LineDistance*m_GridFactor)) * (LineDistance*m_GridFactor); + else + x = (int)((wx-(LineDistance/2)*m_GridFactor)/(LineDistance*m_GridFactor)) * (LineDistance*m_GridFactor); + if(wy >= 0) + y = (int)((wy+(LineDistance/2)*m_GridFactor)/(LineDistance*m_GridFactor)) * (LineDistance*m_GridFactor); + else + y = (int)((wy-(LineDistance/2)*m_GridFactor)/(LineDistance*m_GridFactor)) * (LineDistance*m_GridFactor); + + int OldX = q->m_aPoints[4].x; + int OldY = q->m_aPoints[4].y; + q->m_aPoints[4].x = f2fx(x); + q->m_aPoints[4].y = f2fx(y); + int DiffX = q->m_aPoints[4].x - OldX; + int DiffY = q->m_aPoints[4].y - OldY; + + for(int v = 0; v < 4; v++) + { + q->m_aPoints[v].x += DiffX; + q->m_aPoints[v].y += DiffY; + } + } + else { - q->m_aPoints[v].x += f2fx(wx-s_LastWx); - q->m_aPoints[v].y += f2fx(wy-s_LastWy); + for(int v = 0; v < 5; v++) + { + q->m_aPoints[v].x += f2fx(wx-s_LastWx); + q->m_aPoints[v].y += f2fx(wy-s_LastWy); + } } } - } - else if(s_Operation == OP_ROTATE) - { - for(int v = 0; v < 4; v++) + else if(s_Operation == OP_ROTATE) { - q->m_aPoints[v] = s_RotatePoints[v]; - Rotate(&q->m_aPoints[4], &q->m_aPoints[v], s_RotateAngle); + for(int v = 0; v < 4; v++) + { + q->m_aPoints[v] = s_RotatePoints[v]; + Rotate(&q->m_aPoints[4], &q->m_aPoints[v], s_RotateAngle); + } } } @@ -1335,7 +1359,6 @@ void CEditor::DoQuadPoint(CQuad *pQuad, int QuadIndex, int V) m_SelectedPoints |= 1< Date: Thu, 4 Aug 2011 23:51:54 +0200 Subject: added separator in image menu. Closes #785 --- src/game/editor/editor.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/game/editor/editor.cpp') diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index 4dfda743..40948d82 100644 --- a/src/game/editor/editor.cpp +++ b/src/game/editor/editor.cpp @@ -2426,6 +2426,15 @@ void CEditor::RenderImages(CUIRect ToolBox, CUIRect ToolBar, CUIRect View) } } + + // separator + ToolBox.HSplitTop(5.0f, &Slot, &ToolBox); + ImageCur += 5.0f; + IGraphics::CLineItem LineItem(Slot.x, Slot.y+Slot.h/2, Slot.x+Slot.w, Slot.y+Slot.h/2); + Graphics()->TextureSet(-1); + Graphics()->LinesBegin(); + Graphics()->LinesDraw(&LineItem, 1); + Graphics()->LinesEnd(); } if(ImageCur + 27.0f > ImageStopAt) -- cgit 1.4.1 From 003c0aa28132ade7b89ba5ed001bf819c8d0d381 Mon Sep 17 00:00:00 2001 From: oy Date: Sat, 6 Aug 2011 13:08:29 +0200 Subject: fixed aspect ratio in the editor's image preview. Closes #784 --- src/game/editor/editor.cpp | 3 +++ src/game/editor/popups.cpp | 9 +++++++++ 2 files changed, 12 insertions(+) (limited to 'src/game/editor/editor.cpp') diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index 40948d82..84308ab6 100644 --- a/src/game/editor/editor.cpp +++ b/src/game/editor/editor.cpp @@ -2417,6 +2417,9 @@ void CEditor::RenderImages(CUIRect ToolBox, CUIRect ToolBar, CUIRect View) r.w = r.h; else r.h = r.w; + float Max = (float)(max(m_Map.m_lImages[i]->m_Width, m_Map.m_lImages[i]->m_Height)); + r.w *= m_Map.m_lImages[i]->m_Width/Max; + r.h *= m_Map.m_lImages[i]->m_Height/Max; Graphics()->TextureSet(m_Map.m_lImages[i]->m_TexID); Graphics()->BlendNormal(); Graphics()->QuadsBegin(); diff --git a/src/game/editor/popups.cpp b/src/game/editor/popups.cpp index f29ae7e2..59f731fa 100644 --- a/src/game/editor/popups.cpp +++ b/src/game/editor/popups.cpp @@ -703,7 +703,16 @@ int CEditor::PopupSelectImage(CEditor *pEditor, CUIRect View) } if(ShowImage >= 0 && ShowImage < pEditor->m_Map.m_lImages.size()) + { + if(ImageView.h < ImageView.w) + ImageView.w = ImageView.h; + else + ImageView.h = ImageView.w; + float Max = (float)(max(pEditor->m_Map.m_lImages[ShowImage]->m_Width, pEditor->m_Map.m_lImages[ShowImage]->m_Height)); + ImageView.w *= pEditor->m_Map.m_lImages[ShowImage]->m_Width/Max; + ImageView.h *= pEditor->m_Map.m_lImages[ShowImage]->m_Height/Max; pEditor->Graphics()->TextureSet(pEditor->m_Map.m_lImages[ShowImage]->m_TexID); + } else pEditor->Graphics()->TextureSet(-1); pEditor->Graphics()->QuadsBegin(); -- cgit 1.4.1 From c6fd4a2cc57f8d9dec7164aff98f5a73abc9698d Mon Sep 17 00:00:00 2001 From: Shereef Marzouk Date: Thu, 11 Aug 2011 10:59:14 +0200 Subject: General whitespace and tab cleanup --- src/base/system.c | 8 +- src/engine/client/sound.cpp | 60 ++++++------ src/engine/docs/client_time.txt | 2 +- src/engine/docs/prediction.txt | 2 +- src/engine/docs/server_op.txt | 4 +- src/engine/docs/snapshots.txt | 2 +- src/engine/server/server.cpp | 2 +- src/engine/serverbrowser.h | 2 +- src/engine/shared/console.cpp | 8 +- src/engine/shared/demo.cpp | 2 +- src/engine/shared/masterserver.cpp | 2 +- src/engine/shared/network_console.cpp | 6 +- src/engine/shared/network_console_conn.cpp | 2 +- src/engine/sound.h | 4 +- src/game/client/components/chat.cpp | 2 +- src/game/client/components/hud.cpp | 2 +- src/game/client/components/menus.cpp | 2 +- src/game/client/components/menus_browser.cpp | 4 +- src/game/client/components/menus_ingame.cpp | 2 +- src/game/client/components/menus_settings.cpp | 4 +- src/game/client/components/sounds.cpp | 6 +- src/game/editor/auto_map.cpp | 50 +++++----- src/game/editor/auto_map.h | 8 +- src/game/editor/editor.cpp | 130 +++++++++++++------------- src/game/editor/editor.h | 2 +- src/game/editor/layer_tiles.cpp | 4 +- src/game/editor/popups.cpp | 4 +- src/tools/dilate.cpp | 2 +- 28 files changed, 164 insertions(+), 164 deletions(-) (limited to 'src/game/editor/editor.cpp') diff --git a/src/base/system.c b/src/base/system.c index 466e3ca6..e451cb9a 100644 --- a/src/base/system.c +++ b/src/base/system.c @@ -1119,7 +1119,7 @@ int net_tcp_accept(NETSOCKET sock, NETSOCKET *new_sock, NETADDR *a) sockaddr_len = sizeof(addr); s = accept(sock.ipv4sock, (struct sockaddr *)&addr, &sockaddr_len); - + if (s != -1) { sockaddr_to_netaddr((const struct sockaddr *)&addr, a); @@ -1135,7 +1135,7 @@ int net_tcp_accept(NETSOCKET sock, NETSOCKET *new_sock, NETADDR *a) sockaddr_len = sizeof(addr); s = accept(sock.ipv6sock, (struct sockaddr *)&addr, &sockaddr_len); - + if (s != -1) { sockaddr_to_netaddr((const struct sockaddr *)&addr, a); @@ -1186,7 +1186,7 @@ int net_tcp_send(NETSOCKET sock, const void *data, int size) bytes = send((int)sock.ipv4sock, (const char*)data, size, 0); if(sock.ipv6sock >= 0) bytes = send((int)sock.ipv6sock, (const char*)data, size, 0); - + return bytes; } @@ -1198,7 +1198,7 @@ int net_tcp_recv(NETSOCKET sock, void *data, int maxsize) bytes = recv((int)sock.ipv4sock, (char*)data, maxsize, 0); if(sock.ipv6sock >= 0) bytes = recv((int)sock.ipv6sock, (char*)data, maxsize, 0); - + return bytes; } diff --git a/src/engine/client/sound.cpp b/src/engine/client/sound.cpp index aae52e32..45404d18 100644 --- a/src/engine/client/sound.cpp +++ b/src/engine/client/sound.cpp @@ -19,7 +19,7 @@ enum NUM_SAMPLES = 512, NUM_VOICES = 64, NUM_CHANNELS = 16, - + MAX_FRAMES = 1024 }; @@ -89,9 +89,9 @@ static void Mix(short *pFinalOut, unsigned Frames) // aquire lock while we are mixing lock_wait(m_SoundLock); - + MasterVol = m_SoundVolume; - + for(unsigned i = 0; i < NUM_VOICES; i++) { if(m_aVoices[i].m_pSample) @@ -103,7 +103,7 @@ static void Mix(short *pFinalOut, unsigned Frames) int Step = v->m_pSample->m_Channels; // setup input sources short *pInL = &v->m_pSample->m_pData[v->m_Tick*Step]; short *pInR = &v->m_pSample->m_pData[v->m_Tick*Step+1]; - + unsigned End = v->m_pSample->m_NumFrames-v->m_Tick; int Rvol = v->m_pChannel->m_Vol; @@ -112,7 +112,7 @@ static void Mix(short *pFinalOut, unsigned Frames) // make sure that we don't go outside the sound data if(Frames < End) End = Frames; - + // check if we have a mono sound if(v->m_pSample->m_Channels == 1) pInR = pInL; @@ -133,7 +133,7 @@ static void Mix(short *pFinalOut, unsigned Frames) Lvol = ((Range-p)*Lvol)/Range; else Rvol = ((Range-p)*Rvol)/Range; - + // falloff Lvol = (Lvol*(Range-Dist))/Range; Rvol = (Rvol*(Range-Dist))/Range; @@ -154,7 +154,7 @@ static void Mix(short *pFinalOut, unsigned Frames) pInR += Step; v->m_Tick++; } - + // free voice if not used any more if(v->m_Tick == v->m_pSample->m_NumFrames) { @@ -165,8 +165,8 @@ static void Mix(short *pFinalOut, unsigned Frames) } } } - - + + // release the lock lock_release(m_SoundLock); @@ -201,14 +201,14 @@ int CSound::Init() m_SoundEnabled = 0; m_pGraphics = Kernel()->RequestInterface(); m_pStorage = Kernel()->RequestInterface(); - + SDL_AudioSpec Format; - + m_SoundLock = lock_create(); - + if(!g_Config.m_SndEnable) return 0; - + m_MixingRate = g_Config.m_SndRate; // Set 16-bit stereo audio at 22Khz @@ -229,7 +229,7 @@ int CSound::Init() dbg_msg("client/sound", "sound init successful"); SDL_PauseAudio(0); - + m_SoundEnabled = 1; Update(); // update the volume return 0; @@ -239,17 +239,17 @@ int CSound::Update() { // update volume int WantedVolume = g_Config.m_SndVolume; - + if(!m_pGraphics->WindowActive() && g_Config.m_SndNonactiveMute) WantedVolume = 0; - + if(WantedVolume != m_SoundVolume) { lock_wait(m_SoundLock); m_SoundVolume = WantedVolume; lock_release(m_SoundLock); } - + return 0; } @@ -277,7 +277,7 @@ void CSound::RateConvert(int SampleID) CSample *pSample = &m_aSamples[SampleID]; int NumFrames = 0; short *pNewData = 0; - + // make sure that we need to convert this sound if(!pSample->m_pData || pSample->m_Rate == m_MixingRate) return; @@ -285,7 +285,7 @@ void CSound::RateConvert(int SampleID) // allocate new data NumFrames = (int)((pSample->m_NumFrames/(float)pSample->m_Rate)*m_MixingRate); pNewData = (short *)mem_alloc(NumFrames*pSample->m_Channels*sizeof(short), 1); - + for(int i = 0; i < NumFrames; i++) { // resample TODO: this should be done better, like linear atleast @@ -293,7 +293,7 @@ void CSound::RateConvert(int SampleID) int f = (int)(a*pSample->m_NumFrames); if(f >= pSample->m_NumFrames) f = pSample->m_NumFrames-1; - + // set new data if(pSample->m_Channels == 1) pNewData[i] = pSample->m_pData[f]; @@ -303,7 +303,7 @@ void CSound::RateConvert(int SampleID) pNewData[i*2+1] = pSample->m_pData[f*2+1]; } } - + // free old data and apply new mem_free(pSample->m_pData); pSample->m_pData = pNewData; @@ -321,15 +321,15 @@ int CSound::LoadWV(const char *pFilename) int SampleID = -1; char aError[100]; WavpackContext *pContext; - + // don't waste memory on sound when we are stress testing if(g_Config.m_DbgStress) return -1; - + // no need to load sound when we are running with no sound if(!m_SoundEnabled) return 1; - + if(!m_pStorage) return -1; @@ -372,7 +372,7 @@ int CSound::LoadWV(const char *pFilename) dbg_msg("sound/wv", "file is %d Hz, not 44100 Hz. filename='%s'", snd->rate, filename); return -1; }*/ - + if(BitsPerSample != 16) { dbg_msg("sound/wv", "bps is %d, not 16, filname='%s'", BitsPerSample, pFilename); @@ -382,7 +382,7 @@ int CSound::LoadWV(const char *pFilename) pData = (int *)mem_alloc(4*m_aSamples*m_aChannels, 1); WavpackUnpackSamples(pContext, pData, m_aSamples); // TODO: check return value pSrc = pData; - + pSample->m_pData = (short *)mem_alloc(2*m_aSamples*m_aChannels, 1); pDst = pSample->m_pData; @@ -428,9 +428,9 @@ int CSound::Play(int ChannelID, int SampleID, int Flags, float x, float y) { int VoiceID = -1; int i; - + lock_wait(m_SoundLock); - + // search for voice for(i = 0; i < NUM_VOICES; i++) { @@ -442,7 +442,7 @@ int CSound::Play(int ChannelID, int SampleID, int Flags, float x, float y) break; } } - + // voice found, use it if(VoiceID != -1) { @@ -457,7 +457,7 @@ int CSound::Play(int ChannelID, int SampleID, int Flags, float x, float y) m_aVoices[VoiceID].m_X = (int)x; m_aVoices[VoiceID].m_Y = (int)y; } - + lock_release(m_SoundLock); return VoiceID; } diff --git a/src/engine/docs/client_time.txt b/src/engine/docs/client_time.txt index bc76f91c..0d4dd53e 100644 --- a/src/engine/docs/client_time.txt +++ b/src/engine/docs/client_time.txt @@ -6,6 +6,6 @@ predtick, predintratick prevtick tick predtick 4 8 14 |---------------------|---------------------| - 0 <- intratick -> 1 + 0 <- intratick -> 1 0 <- ticktime(in s)-> X 0 <- predintratick?-> 1 diff --git a/src/engine/docs/prediction.txt b/src/engine/docs/prediction.txt index d5771d1a..e740b1e8 100644 --- a/src/engine/docs/prediction.txt +++ b/src/engine/docs/prediction.txt @@ -8,7 +8,7 @@ Predicted input sent to the server can be retrived by calling > { > int tick; > prediction_reset(); -> +> > for(tick = client_tick()+1; tick <= client_predtick(); tick++) > { > MY_INPUT *input = (MY_INPUT *)client_get_input(); diff --git a/src/engine/docs/server_op.txt b/src/engine/docs/server_op.txt index 59181e62..c0a054c4 100644 --- a/src/engine/docs/server_op.txt +++ b/src/engine/docs/server_op.txt @@ -25,13 +25,13 @@ while running send snapshot end for end - + process new network messages end while unload map (end) - + Section: Reinit diff --git a/src/engine/docs/snapshots.txt b/src/engine/docs/snapshots.txt index 647b049a..adb84863 100644 --- a/src/engine/docs/snapshots.txt +++ b/src/engine/docs/snapshots.txt @@ -48,7 +48,7 @@ After a snapshot have been created, compression is applyed to reduce the bandwid Topic: Interval -The interval for how often a client recives a snapshot changes during the course of the connection. There are three different snapshot rates. +The interval for how often a client recives a snapshot changes during the course of the connection. There are three different snapshot rates. - *Init*. 5 snapshots per second. Used when a client is connecting and used until the client has acknowlaged a snapshot. This mechanism is used because the first snapshot because no delta compression can be done. diff --git a/src/engine/server/server.cpp b/src/engine/server/server.cpp index 6f6d9e1c..93e96db9 100644 --- a/src/engine/server/server.cpp +++ b/src/engine/server/server.cpp @@ -672,7 +672,7 @@ void CServer::SendRconCmdRem(const IConsole::CCommandInfo *pCommandInfo, int Cli void CServer::UpdateClientRconCommands() { int ClientID = Tick() % MAX_CLIENTS; - + if(m_aClients[ClientID].m_State != CClient::STATE_EMPTY && m_aClients[ClientID].m_Authed) { int ConsoleAccessLevel = m_aClients[ClientID].m_Authed == AUTHED_ADMIN ? IConsole::ACCESS_LEVEL_ADMIN : IConsole::ACCESS_LEVEL_MOD; diff --git a/src/engine/serverbrowser.h b/src/engine/serverbrowser.h index 1a49eaf0..79919b09 100644 --- a/src/engine/serverbrowser.h +++ b/src/engine/serverbrowser.h @@ -24,7 +24,7 @@ public: int m_Country; int m_Score; bool m_Player; - + int m_FriendState; }; diff --git a/src/engine/shared/console.cpp b/src/engine/shared/console.cpp index e4cb1991..de5116c1 100644 --- a/src/engine/shared/console.cpp +++ b/src/engine/shared/console.cpp @@ -665,7 +665,7 @@ void CConsole::Register(const char *pName, const char *pParams, pCommand->m_pName = pName; pCommand->m_pHelp = pHelp; pCommand->m_pParams = pParams; - + pCommand->m_Flags = Flags; pCommand->m_Temp = false; @@ -699,7 +699,7 @@ void CConsole::RegisterTemp(const char *pName, const char *pParams, int Flags, c } pCommand->m_pfnCallback = 0; - pCommand->m_pUserData = 0; + pCommand->m_pUserData = 0; pCommand->m_Flags = Flags; pCommand->m_Temp = true; @@ -729,7 +729,7 @@ void CConsole::DeregisterTemp(const char *pName) break; } } - + // add to recycle list if(pRemoved) { @@ -742,7 +742,7 @@ void CConsole::DeregisterTempAll() { // set non temp as first one for(; m_pFirstCommand && m_pFirstCommand->m_Temp; m_pFirstCommand = m_pFirstCommand->m_pNext); - + // remove temp entries from command list for(CCommand *pCommand = m_pFirstCommand; pCommand && pCommand->m_pNext; pCommand = pCommand->m_pNext) { diff --git a/src/engine/shared/demo.cpp b/src/engine/shared/demo.cpp index 51dd51d9..2bd7c28a 100644 --- a/src/engine/shared/demo.cpp +++ b/src/engine/shared/demo.cpp @@ -775,7 +775,7 @@ void CDemoPlayer::GetDemoName(char *pBuffer, int BufferSize) const else if(*pFileName == '.') pEnd = pFileName; } - + int Length = pEnd > pExtractedName ? min(BufferSize, (int)(pEnd-pExtractedName+1)) : BufferSize; str_copy(pBuffer, pExtractedName, Length); } diff --git a/src/engine/shared/masterserver.cpp b/src/engine/shared/masterserver.cpp index 1271eeaf..eb63bab5 100644 --- a/src/engine/shared/masterserver.cpp +++ b/src/engine/shared/masterserver.cpp @@ -157,7 +157,7 @@ public: Added = true; break; } - + if(!Added) { for(int i = 0; i < MAX_MASTERSERVERS; ++i) diff --git a/src/engine/shared/network_console.cpp b/src/engine/shared/network_console.cpp index 13ed3751..cfa081a2 100644 --- a/src/engine/shared/network_console.cpp +++ b/src/engine/shared/network_console.cpp @@ -56,7 +56,7 @@ int CNetConsole::AcceptClient(NETSOCKET Socket, const NETADDR *pAddr) { char aError[256] = { 0 }; int FreeSlot = -1; - + // look for free slot or multiple client for(int i = 0; i < NET_MAX_CONSOLE_CLIENTS; i++) { @@ -115,7 +115,7 @@ int CNetConsole::Update() } else str_format(aBuf, sizeof(aBuf), "You have been banned for life"); - + net_tcp_send(Socket, aBuf, str_length(aBuf)); net_tcp_close(Socket); } @@ -170,7 +170,7 @@ bool CNetConsole::AddBan(NETADDR Addr, int Seconds) { if(m_NumBans == MAX_BANS) return false; - + Addr.port = 0; int Index = FindBan(Addr); if(Index == -1) diff --git a/src/engine/shared/network_console_conn.cpp b/src/engine/shared/network_console_conn.cpp index 75b581fa..9bc163af 100644 --- a/src/engine/shared/network_console_conn.cpp +++ b/src/engine/shared/network_console_conn.cpp @@ -181,6 +181,6 @@ int CConsoleNetConnection::Send(const char *pLine) pData += Send; Length -= Send; } - + return 0; } diff --git a/src/engine/sound.h b/src/engine/sound.h index f55a978d..fa5bfc85 100644 --- a/src/engine/sound.h +++ b/src/engine/sound.h @@ -19,10 +19,10 @@ public: virtual bool IsSoundEnabled() = 0; virtual int LoadWV(const char *pFilename) = 0; - + virtual void SetChannel(int ChannelID, float Volume, float Panning) = 0; virtual void SetListenerPos(float x, float y) = 0; - + virtual int PlayAt(int ChannelID, int SampleID, int Flags, float x, float y) = 0; virtual int Play(int ChannelID, int SampleID, int Flags) = 0; virtual void Stop(int SampleID) = 0; diff --git a/src/game/client/components/chat.cpp b/src/game/client/components/chat.cpp index aba38bf6..a3bf5252 100644 --- a/src/game/client/components/chat.cpp +++ b/src/game/client/components/chat.cpp @@ -283,7 +283,7 @@ void CChat::AddLine(int ClientID, int Team, const char *pLine) m_aLines[m_CurrentLine].m_ClientID = ClientID; m_aLines[m_CurrentLine].m_Team = Team; m_aLines[m_CurrentLine].m_NameColor = -2; - + // check for highlighted name const char *pHL = str_find_nocase(pLine, m_pClient->m_aClients[m_pClient->m_Snap.m_LocalClientID].m_aName); if(pHL) diff --git a/src/game/client/components/hud.cpp b/src/game/client/components/hud.cpp index 11343912..17365116 100644 --- a/src/game/client/components/hud.cpp +++ b/src/game/client/components/hud.cpp @@ -108,7 +108,7 @@ void CHud::RenderScoreHud() if(GameFlags&GAMEFLAG_FLAGS) { - int BlinkTimer = (m_pClient->m_FlagDropTick[t] != 0 && + int BlinkTimer = (m_pClient->m_FlagDropTick[t] != 0 && (Client()->GameTick()-m_pClient->m_FlagDropTick[t])/Client()->GameTickSpeed() >= 25) ? 10 : 20; if(FlagCarrier[t] == FLAG_ATSTAND || (FlagCarrier[t] == FLAG_TAKEN && ((Client()->GameTick()/BlinkTimer)&1))) { diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp index 8f330f78..8813c667 100644 --- a/src/game/client/components/menus.cpp +++ b/src/game/client/components/menus.cpp @@ -1108,7 +1108,7 @@ int CMenus::Render() Box.HSplitBottom(24.f, &Box, &Part); Box.HSplitBottom(20.f, &Box, 0); Box.VMargin(20.0f, &Box); - + static int ActSelection = -2; if(ActSelection == -2) ActSelection = g_Config.m_BrFilterCountryIndex; diff --git a/src/game/client/components/menus_browser.cpp b/src/game/client/components/menus_browser.cpp index 8501c67d..825fe3da 100644 --- a/src/game/client/components/menus_browser.cpp +++ b/src/game/client/components/menus_browser.cpp @@ -516,7 +516,7 @@ void CMenus::RenderServerbrowserFilters(CUIRect View) ServerFilter.HSplitTop(20.0f, &Button, &ServerFilter); if (DoButton_CheckBox((char *)&g_Config.m_BrFilterPureMap, Localize("Standard map"), g_Config.m_BrFilterPureMap, &Button)) g_Config.m_BrFilterPureMap ^= 1; - + ServerFilter.HSplitTop(20.0f, &Button, &ServerFilter); if (DoButton_CheckBox((char *)&g_Config.m_BrFilterGametypeStrict, Localize("Strict gametype filter"), g_Config.m_BrFilterGametypeStrict, &Button)) g_Config.m_BrFilterGametypeStrict ^= 1; @@ -563,7 +563,7 @@ void CMenus::RenderServerbrowserFilters(CUIRect View) Button.HMargin(3.0f, &Button); if(DoButton_CheckBox(&g_Config.m_BrFilterCountry, Localize("Player country:"), g_Config.m_BrFilterCountry, &Button)) g_Config.m_BrFilterCountry ^= 1; - + float OldWidth = Rect.w; Rect.w = Rect.h*2; Rect.x += (OldWidth-Rect.w)/2.0f; diff --git a/src/game/client/components/menus_ingame.cpp b/src/game/client/components/menus_ingame.cpp index a809aef0..1afcefe5 100644 --- a/src/game/client/components/menus_ingame.cpp +++ b/src/game/client/components/menus_ingame.cpp @@ -391,7 +391,7 @@ void CMenus::RenderServerControlKick(CUIRect MainView, bool FilterSpectators) { if(!m_pClient->m_Snap.m_paInfoByTeam[i]) continue; - + int Index = m_pClient->m_Snap.m_paInfoByTeam[i]->m_ClientID; if(Index == m_pClient->m_Snap.m_LocalClientID || FilterSpectators && m_pClient->m_Snap.m_paInfoByTeam[i]->m_Team == TEAM_SPECTATORS) continue; diff --git a/src/game/client/components/menus_settings.cpp b/src/game/client/components/menus_settings.cpp index 51fdbd29..7692ac27 100644 --- a/src/game/client/components/menus_settings.cpp +++ b/src/game/client/components/menus_settings.cpp @@ -543,7 +543,7 @@ void CMenus::RenderSettingsControls(CUIRect MainView) WeaponSettings.HSplitTop(14.0f+5.0f+10.0f, 0, &WeaponSettings); UiDoGetButtons(5, 12, WeaponSettings); } - + // defaults { ResetButton.HSplitTop(10.0f, 0, &ResetButton); @@ -554,7 +554,7 @@ void CMenus::RenderSettingsControls(CUIRect MainView) if(DoButton_Menu((void*)&s_DefaultButton, Localize("Reset to defaults"), 0, &ResetButton)) m_pClient->m_pBinds->SetDefaults(); } - + // voting settings { VotingSettings.VSplitLeft(10.0f, 0, &VotingSettings); diff --git a/src/game/client/components/sounds.cpp b/src/game/client/components/sounds.cpp index c4ade00e..65fb56fb 100644 --- a/src/game/client/components/sounds.cpp +++ b/src/game/client/components/sounds.cpp @@ -144,7 +144,7 @@ void CSounds::Play(int Chn, int SetId, float Vol, vec2 Pos) if(!pSet->m_NumSounds) return; - + int Flags = 0; if(Chn == CHN_MUSIC) Flags = ISound::FLAG_LOOP; @@ -170,9 +170,9 @@ void CSounds::Stop(int SetId) { if(m_WaitForSoundJob || SetId < 0 || SetId >= g_pData->m_NumSounds) return; - + CDataSoundset *pSet = &g_pData->m_aSounds[SetId]; - + for(int i = 0; i < pSet->m_NumSounds; i++) Sound()->Stop(pSet->m_aSounds[i].m_Id); } diff --git a/src/game/editor/auto_map.cpp b/src/game/editor/auto_map.cpp index 528e459b..3abcf0f4 100644 --- a/src/game/editor/auto_map.cpp +++ b/src/game/editor/auto_map.cpp @@ -20,15 +20,15 @@ void CAutoMapper::Load(const char* pTileName) IOHANDLE RulesFile = m_pEditor->Storage()->OpenFile(aPath, IOFLAG_READ, IStorage::TYPE_ALL); if(!RulesFile) return; - + CLineReader LineReader; LineReader.Init(RulesFile); - + CConfiguration *pCurrentConf = 0; CIndexRule *pCurrentIndex = 0; - + char aBuf[256]; - + // read each line while(char *pLine = LineReader.Get()) { @@ -40,11 +40,11 @@ void CAutoMapper::Load(const char* pTileName) { // new configuration, get the name pLine++; - + CConfiguration NewConf; int ID = m_lConfigs.add(NewConf); pCurrentConf = &m_lConfigs[ID]; - + str_copy(pCurrentConf->m_aName, pLine, str_length(pLine)); } else @@ -54,15 +54,15 @@ void CAutoMapper::Load(const char* pTileName) // new index int ID = 0; char aFlip[128] = ""; - + sscanf(pLine, "Index %d %127s", &ID, aFlip); - + CIndexRule NewIndexRule; NewIndexRule.m_ID = ID; NewIndexRule.m_Flag = 0; NewIndexRule.m_RandomValue = 0; NewIndexRule.m_BaseTile = false; - + if(str_length(aFlip) > 0) { if(!str_comp(aFlip, "XFLIP")) @@ -70,7 +70,7 @@ void CAutoMapper::Load(const char* pTileName) else if(!str_comp(aFlip, "YFLIP")) NewIndexRule.m_Flag = TILEFLAG_HFLIP; } - + // add the index rule object and make it current int ArrayID = pCurrentConf->m_aIndexRules.add(NewIndexRule); pCurrentIndex = &pCurrentConf->m_aIndexRules[ArrayID]; @@ -85,9 +85,9 @@ void CAutoMapper::Load(const char* pTileName) char aValue[128]; int Value = CPosRule::EMPTY; bool IndexValue = false; - + sscanf(pLine, "Pos %d %d %127s", &x, &y, aValue); - + if(!str_comp(aValue, "FULL")) Value = CPosRule::FULL; else if(!str_comp_num(aValue, "INDEX", 5)) @@ -106,12 +106,12 @@ void CAutoMapper::Load(const char* pTileName) } } } - + io_close(RulesFile); - + str_format(aBuf, sizeof(aBuf),"loaded %s", aPath); m_pEditor->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "editor", aBuf); - + m_FileLoaded = true; } @@ -127,14 +127,14 @@ void CAutoMapper::Proceed(CLayerTiles *pLayer, int ConfigID) { if(!m_FileLoaded || pLayer->m_Readonly || ConfigID < 0 || ConfigID >= m_lConfigs.size()) return; - + CConfiguration *pConf = &m_lConfigs[ConfigID]; - + if(!pConf->m_aIndexRules.size()) return; - + int BaseTile = 1; - + // find base tile if there is one for(int i = 0; i < pConf->m_aIndexRules.size(); ++i) { @@ -144,7 +144,7 @@ void CAutoMapper::Proceed(CLayerTiles *pLayer, int ConfigID) break; } } - + // auto map ! int MaxIndex = pLayer->m_Width*pLayer->m_Height; for(int y = 0; y < pLayer->m_Height; y++) @@ -159,7 +159,7 @@ void CAutoMapper::Proceed(CLayerTiles *pLayer, int ConfigID) if(y == 0 || y == pLayer->m_Height-1 || x == 0 || x == pLayer->m_Width-1) continue; - + for(int i = 0; i < pConf->m_aIndexRules.size(); ++i) { if(pConf->m_aIndexRules[i].m_BaseTile) @@ -170,7 +170,7 @@ void CAutoMapper::Proceed(CLayerTiles *pLayer, int ConfigID) { CPosRule *pRule = &pConf->m_aIndexRules[i].m_aRules[j]; int CheckIndex = (y+pRule->m_Y)*pLayer->m_Width+(x+pRule->m_X); - + if(CheckIndex < 0 || CheckIndex >= MaxIndex) RespectRules = false; else @@ -184,15 +184,15 @@ void CAutoMapper::Proceed(CLayerTiles *pLayer, int ConfigID) { if(pLayer->m_pTiles[CheckIndex].m_Index > 0 && pRule->m_Value == CPosRule::EMPTY) RespectRules = false; - + if(pLayer->m_pTiles[CheckIndex].m_Index == 0 && pRule->m_Value == CPosRule::FULL) RespectRules = false; } } } - + if(RespectRules && - (pConf->m_aIndexRules[i].m_RandomValue <= 1 || (int)((float)rand() / ((float)RAND_MAX + 1) * pConf->m_aIndexRules[i].m_RandomValue) == 1)) + (pConf->m_aIndexRules[i].m_RandomValue <= 1 || (int)((float)rand() / ((float)RAND_MAX + 1) * pConf->m_aIndexRules[i].m_RandomValue) == 1)) { pTile->m_Index = pConf->m_aIndexRules[i].m_ID; pTile->m_Flags = pConf->m_aIndexRules[i].m_Flag; diff --git a/src/game/editor/auto_map.h b/src/game/editor/auto_map.h index ee570378..c5537d4f 100644 --- a/src/game/editor/auto_map.h +++ b/src/game/editor/auto_map.h @@ -11,7 +11,7 @@ class CAutoMapper int m_Y; int m_Value; bool m_IndexValue; - + enum { EMPTY=0, @@ -33,16 +33,16 @@ class CAutoMapper array m_aIndexRules; char m_aName[128]; }; - + public: CAutoMapper(class CEditor *pEditor); - + void Load(const char* pTileName); void Proceed(class CLayerTiles *pLayer, int ConfigID); int ConfigNamesNum() { return m_lConfigs.size(); } const char* GetConfigName(int Index); - + const bool IsLoaded() { return m_FileLoaded; } private: array m_lConfigs; diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index 84308ab6..b7c1d0cb 100644 --- a/src/game/editor/editor.cpp +++ b/src/game/editor/editor.cpp @@ -164,7 +164,7 @@ void CEditorImage::AnalyseTileFlags() int tw = m_Width/16; // tilesizes int th = m_Height/16; if ( tw == th ) - { + { unsigned char *pPixelData = (unsigned char *)m_pData; int TileID = 0; @@ -381,8 +381,8 @@ float CEditor::UiDoScrollbarV(const void *pID, const CUIRect *pRect, float Curre Handle.y += (pRect->h-Handle.h)*Current; // logic - float Ret = Current; - int Inside = UI()->MouseInside(&Handle); + float Ret = Current; + int Inside = UI()->MouseInside(&Handle); if(UI()->ActiveItem() == pID) { @@ -423,7 +423,7 @@ float CEditor::UiDoScrollbarV(const void *pID, const CUIRect *pRect, float Curre Slider.Margin(5.0f, &Slider); RenderTools()->DrawUIRect(&Slider, vec4(1,1,1,0.25f)*ButtonColorMul(pID), CUI::CORNER_ALL, 2.5f); - return Ret; + return Ret; } vec4 CEditor::GetButtonColor(const void *pID, int Checked) @@ -490,7 +490,7 @@ int CEditor::DoButton_File(const void *pID, const char *pText, int Checked, cons int CEditor::DoButton_Menu(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags, const char *pToolTip) { CUIRect r = *pRect; - RenderTools()->DrawUIRect(&r, vec4(0.5f, 0.5f, 0.5f, 1.0f), CUI::CORNER_T, 3.0f); + RenderTools()->DrawUIRect(&r, vec4(0.5f, 0.5f, 0.5f, 1.0f), CUI::CORNER_T, 3.0f); r = *pRect; r.VMargin(5.0f, &r); @@ -515,18 +515,18 @@ int CEditor::DoButton_MenuItem(const void *pID, const char *pText, int Checked, int CEditor::DoButton_Tab(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags, const char *pToolTip) { RenderTools()->DrawUIRect(pRect, GetButtonColor(pID, Checked), CUI::CORNER_T, 5.0f); - CUIRect NewRect = *pRect; - NewRect.y += NewRect.h/2.0f-7.0f; - UI()->DoLabel(&NewRect, pText, 10, 0, -1); + CUIRect NewRect = *pRect; + NewRect.y += NewRect.h/2.0f-7.0f; + UI()->DoLabel(&NewRect, pText, 10, 0, -1); return DoButton_Editor_Common(pID, pText, Checked, pRect, Flags, pToolTip); } int CEditor::DoButton_Ex(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags, const char *pToolTip, int Corners, float FontSize) { RenderTools()->DrawUIRect(pRect, GetButtonColor(pID, Checked), Corners, 3.0f); - CUIRect NewRect = *pRect; - NewRect.HMargin(NewRect.h/2.0f-FontSize/2.0f-1.0f, &NewRect); - UI()->DoLabel(&NewRect, pText, FontSize, 0, -1); + CUIRect NewRect = *pRect; + NewRect.HMargin(NewRect.h/2.0f-FontSize/2.0f-1.0f, &NewRect); + UI()->DoLabel(&NewRect, pText, FontSize, 0, -1); return DoButton_Editor_Common(pID, pText, Checked, pRect, Flags, pToolTip); } @@ -550,7 +550,7 @@ void CEditor::RenderGrid(CLayerGroup *pGroup) return; float aGroupPoints[4]; - pGroup->Mapping(aGroupPoints); + pGroup->Mapping(aGroupPoints); float w = UI()->Screen()->w; float h = UI()->Screen()->h; @@ -562,7 +562,7 @@ void CEditor::RenderGrid(CLayerGroup *pGroup) int XGridOffset = XOffset % m_GridFactor; int YGridOffset = YOffset % m_GridFactor; - Graphics()->TextureSet(-1); + Graphics()->TextureSet(-1); Graphics()->LinesBegin(); for(int i = 0; i < (int)w; i++) @@ -601,9 +601,9 @@ void CEditor::RenderBackground(CUIRect View, int Texture, float Size, float Brig int CEditor::UiDoValueSelector(void *pID, CUIRect *pRect, const char *pLabel, int Current, int Min, int Max, int Step, float Scale, const char *pToolTip) { - // logic - static float s_Value; - int Inside = UI()->MouseInside(pRect); + // logic + static float s_Value; + int Inside = UI()->MouseInside(pRect); if(UI()->ActiveItem() == pID) { @@ -652,9 +652,9 @@ int CEditor::UiDoValueSelector(void *pID, CUIRect *pRect, const char *pLabel, in char aBuf[128]; str_format(aBuf, sizeof(aBuf),"%s %d", pLabel, Current); RenderTools()->DrawUIRect(pRect, GetButtonColor(pID, 0), CUI::CORNER_ALL, 5.0f); - pRect->y += pRect->h/2.0f-7.0f; - UI()->DoLabel(pRect, aBuf, 10, 0, -1); - + pRect->y += pRect->h/2.0f-7.0f; + UI()->DoLabel(pRect, aBuf, 10, 0, -1); + return Current; } @@ -713,7 +713,7 @@ void CEditor::CallbackAppendMap(const char *pFileName, int StorageType, void *pU pEditor->m_aFileName[0] = 0; else pEditor->SortImages(); - + pEditor->m_Dialog = DIALOG_NONE; } void CEditor::CallbackSaveMap(const char *pFileName, int StorageType, void *pUser) @@ -734,7 +734,7 @@ void CEditor::CallbackSaveMap(const char *pFileName, int StorageType, void *pUse pEditor->m_ValidSaveFilename = StorageType == IStorage::TYPE_SAVE && pEditor->m_pFileDialogPath == pEditor->m_aFileDialogCurrentFolder; pEditor->m_Map.m_Modified = false; } - + pEditor->m_Dialog = DIALOG_NONE; } @@ -742,11 +742,11 @@ void CEditor::DoToolbar(CUIRect ToolBar) { CUIRect TB_Top, TB_Bottom; CUIRect Button; - + ToolBar.HSplitTop(ToolBar.h/2.0f, &TB_Top, &TB_Bottom); - - TB_Top.HSplitBottom(2.5f, &TB_Top, 0); - TB_Bottom.HSplitTop(2.5f, 0, &TB_Bottom); + + TB_Top.HSplitBottom(2.5f, &TB_Top, 0); + TB_Bottom.HSplitTop(2.5f, 0, &TB_Bottom); // ctrl+o to open if(Input()->KeyDown('o') && (Input()->KeyPressed(KEY_LCTRL) || Input()->KeyPressed(KEY_RCTRL))) @@ -763,7 +763,7 @@ void CEditor::DoToolbar(CUIRect ToolBar) // ctrl+s to save if(Input()->KeyDown('s') && (Input()->KeyPressed(KEY_LCTRL) || Input()->KeyPressed(KEY_RCTRL))) { - if(m_aFileName[0] && m_ValidSaveFilename) + if(m_aFileName[0] && m_ValidSaveFilename) { str_copy(m_aFileSaveName, m_aFileName, sizeof(m_aFileSaveName)); m_PopupEventType = POPEVENT_SAVE; @@ -947,13 +947,13 @@ void CEditor::DoToolbar(CUIRect ToolBar) } } } - + // tile manipulation { TB_Bottom.VSplitLeft(40.0f, &Button, &TB_Bottom); static int s_BorderBut = 0; CLayerTiles *pT = (CLayerTiles *)GetSelectedLayerType(0, LAYERTYPE_TILES); - + if(DoButton_Editor(&s_BorderBut, "Border", pT?0:-1, &Button, 0, "Adds border tiles")) { if(pT) @@ -1102,14 +1102,14 @@ void CEditor::DoQuad(CQuad *q, int Index) y = (int)((wy+(LineDistance/2)*m_GridFactor)/(LineDistance*m_GridFactor)) * (LineDistance*m_GridFactor); else y = (int)((wy-(LineDistance/2)*m_GridFactor)/(LineDistance*m_GridFactor)) * (LineDistance*m_GridFactor); - + int OldX = q->m_aPoints[4].x; int OldY = q->m_aPoints[4].y; q->m_aPoints[4].x = f2fx(x); q->m_aPoints[4].y = f2fx(y); int DiffX = q->m_aPoints[4].x - OldX; int DiffY = q->m_aPoints[4].y - OldY; - + for(int v = 0; v < 4; v++) { q->m_aPoints[v].x += DiffX; @@ -1198,7 +1198,7 @@ void CEditor::DoQuad(CQuad *q, int Index) { if(m_SelectedQuad != Index) m_SelectedPoints = 0; - m_SelectedQuad = Index; + m_SelectedQuad = Index; s_Operation = OP_CONTEXT_MENU; UI()->SetActiveItem(pID); } @@ -1295,12 +1295,12 @@ void CEditor::DoQuadPoint(CQuad *pQuad, int QuadIndex, int V) for(int m = 0; m < 4; m++) if(m_SelectedPoints&(1<m_aTexcoords[m].x += f2fx(dx*0.001f); pQuad->m_aTexcoords[(m+2)%4].x += f2fx(dx*0.001f); - + pQuad->m_aTexcoords[m].y += f2fx(dy*0.001f); pQuad->m_aTexcoords[m^1].y += f2fx(dy*0.001f); } @@ -1590,8 +1590,8 @@ void CEditor::DoMapEditor(CUIRect View, CUIRect ToolBar) { if(!UI()->MouseButton(0)) { - for(int k = 0; k < NumEditLayers; k++) - pEditLayers[k]->FillSelection(m_Brush.IsEmpty(), m_Brush.m_lLayers[0], r); + for(int k = 0; k < NumEditLayers; k++) + pEditLayers[k]->FillSelection(m_Brush.IsEmpty(), m_Brush.m_lLayers[0], r); } else { @@ -1623,10 +1623,10 @@ void CEditor::DoMapEditor(CUIRect View, CUIRect ToolBar) } } - + CLayerTiles *pLayer = (CLayerTiles*)GetSelectedLayerType(0, LAYERTYPE_TILES); if((Input()->KeyPressed(KEY_LSHIFT) || Input()->KeyPressed(KEY_RSHIFT)) && pLayer) - s_Operation = OP_BRUSH_PAINT; + s_Operation = OP_BRUSH_PAINT; } if(!m_Brush.IsEmpty()) @@ -1736,7 +1736,7 @@ void CEditor::DoMapEditor(CUIRect View, CUIRect ToolBar) { CLayerGroup *g = m_Map.m_pGameGroup; g->MapScreen(); - + Graphics()->TextureSet(-1); Graphics()->LinesBegin(); @@ -1935,7 +1935,7 @@ int CEditor::DoProperties(CUIRect *pToolBox, CProperty *pProps, int *pIDs, int * if(pProps[i].m_Value < 0) str_copy(aBuf, "None", sizeof(aBuf)); else - str_format(aBuf, sizeof(aBuf),"%s", m_Map.m_lImages[pProps[i].m_Value]->m_aName); + str_format(aBuf, sizeof(aBuf),"%s", m_Map.m_lImages[pProps[i].m_Value]->m_aName); if(DoButton_Editor(&pIDs[i], aBuf, 0, &Shifter, 0, 0)) PopupSelectImageInvoke(pProps[i].m_Value, UI()->MouseX(), UI()->MouseY()); @@ -2174,8 +2174,8 @@ void CEditor::ReplaceImage(const char *pFileName, int StorageType, void *pUser) pEditor->SortImages(); for(int i = 0; i < pEditor->m_Map.m_lImages.size(); ++i) { - if(!str_comp(pEditor->m_Map.m_lImages[i]->m_aName, pImg->m_aName)) - pEditor->m_SelectedImage = i; + if(!str_comp(pEditor->m_Map.m_lImages[i]->m_aName, pImg->m_aName)) + pEditor->m_SelectedImage = i; } pEditor->m_Dialog = DIALOG_NONE; } @@ -2192,8 +2192,8 @@ void CEditor::AddImage(const char *pFileName, int StorageType, void *pUser) ExtractName(pFileName, aBuf, sizeof(aBuf)); for(int i = 0; i < pEditor->m_Map.m_lImages.size(); ++i) { - if(!str_comp(pEditor->m_Map.m_lImages[i]->m_aName, aBuf)) - return; + if(!str_comp(pEditor->m_Map.m_lImages[i]->m_aName, aBuf)) + return; } CEditorImage *pImg = new CEditorImage(pEditor); @@ -2319,7 +2319,7 @@ void CEditor::SortImages() gs_pSortedIndex = 0; } } - + void CEditor::RenderImages(CUIRect ToolBox, CUIRect ToolBar, CUIRect View) { @@ -2750,7 +2750,7 @@ void CEditor::InvokeFileDialog(int StorageType, int FileType, const char *pTitle str_copy(m_aFileDialogFileName, pDefaultName, sizeof(m_aFileDialogFileName)); if(pBasePath) str_copy(m_aFileDialogCurrentFolder, pBasePath, sizeof(m_aFileDialogCurrentFolder)); - + FilelistPopulate(m_FileDialogStorageType); m_Dialog = DIALOG_FILE; @@ -2770,10 +2770,10 @@ void CEditor::RenderModebar(CUIRect View) const char *pButName = m_Mode == MODE_LAYERS ? "Layers" : "Images"; if(DoButton_Tab(&s_Button, pButName, 0, &Button, 0, "Switch between images and layers managment.")) { - if(m_Mode == MODE_LAYERS) - m_Mode = MODE_IMAGES; - else - m_Mode = MODE_LAYERS; + if(m_Mode == MODE_LAYERS) + m_Mode = MODE_IMAGES; + else + m_Mode = MODE_LAYERS; } } @@ -3127,7 +3127,7 @@ void CEditor::RenderEnvelopeEditor(CUIRect View) UI()->SetActiveItem(0); } else - { + { if(Input()->KeyPressed(KEY_LSHIFT) || Input()->KeyPressed(KEY_RSHIFT)) { if(i != 0) @@ -3482,12 +3482,12 @@ void CEditor::Reset(bool CreateDefault) m_SelectedPoints = 0; m_SelectedEnvelope = 0; m_SelectedImage = 0; - + m_WorldOffsetX = 0; m_WorldOffsetY = 0; m_EditorOffsetX = 0.0f; m_EditorOffsetY = 0.0f; - + m_WorldZoom = 1.0f; m_ZoomLevel = 200; @@ -3633,19 +3633,19 @@ void CEditor::Init() void CEditor::DoMapBorder() { - CLayerTiles *pT = (CLayerTiles *)GetSelectedLayerType(0, LAYERTYPE_TILES); - - for(int i = 0; i < pT->m_Width*2; ++i) - pT->m_pTiles[i].m_Index = 1; - - for(int i = 0; i < pT->m_Width*pT->m_Height; ++i) - { - if(i%pT->m_Width < 2 || i%pT->m_Width > pT->m_Width-3) - pT->m_pTiles[i].m_Index = 1; - } - - for(int i = (pT->m_Width*(pT->m_Height-2)); i < pT->m_Width*pT->m_Height; ++i) - pT->m_pTiles[i].m_Index = 1; + CLayerTiles *pT = (CLayerTiles *)GetSelectedLayerType(0, LAYERTYPE_TILES); + + for(int i = 0; i < pT->m_Width*2; ++i) + pT->m_pTiles[i].m_Index = 1; + + for(int i = 0; i < pT->m_Width*pT->m_Height; ++i) + { + if(i%pT->m_Width < 2 || i%pT->m_Width > pT->m_Width-3) + pT->m_pTiles[i].m_Index = 1; + } + + for(int i = (pT->m_Width*(pT->m_Height-2)); i < pT->m_Width*pT->m_Height; ++i) + pT->m_pTiles[i].m_Index = 1; } void CEditor::UpdateAndRender() diff --git a/src/game/editor/editor.h b/src/game/editor/editor.h index 1a904953..db99a78c 100644 --- a/src/game/editor/editor.h +++ b/src/game/editor/editor.h @@ -713,7 +713,7 @@ public: void PopupSelectGametileOpInvoke(float x, float y); int PopupSelectGameTileOpResult(); - + void PopupSelectConfigAutoMapInvoke(float x, float y); int PopupSelectConfigAutoMapResult(); diff --git a/src/game/editor/layer_tiles.cpp b/src/game/editor/layer_tiles.cpp index eb78a23d..7532c1bd 100644 --- a/src/game/editor/layer_tiles.cpp +++ b/src/game/editor/layer_tiles.cpp @@ -363,7 +363,7 @@ void CLayerTiles::ShowInfo() int CLayerTiles::RenderProperties(CUIRect *pToolBox) { CUIRect Button; - + bool InGameGroup = !find_linear(m_pEditor->m_Map.m_pGameGroup->m_lLayers.all(), this).empty(); if(m_pEditor->m_Map.m_pGameLayer != this) { @@ -373,7 +373,7 @@ int CLayerTiles::RenderProperties(CUIRect *pToolBox) pToolBox->HSplitBottom(12.0f, pToolBox, &Button); if(m_pEditor->DoButton_Editor(&s_AutoMapperButton, "Auto map", 0, &Button, 0, "")) m_pEditor->PopupSelectConfigAutoMapInvoke(m_pEditor->UI()->MouseX(), m_pEditor->UI()->MouseY()); - + int Result = m_pEditor->PopupSelectConfigAutoMapResult(); if(Result > -1) { diff --git a/src/game/editor/popups.cpp b/src/game/editor/popups.cpp index 0d8036e3..a97146aa 100644 --- a/src/game/editor/popups.cpp +++ b/src/game/editor/popups.cpp @@ -811,7 +811,7 @@ int CEditor::PopupSelectConfigAutoMap(CEditor *pEditor, CUIRect View) CUIRect Button; static int s_AutoMapperConfigButtons[256]; CAutoMapper *pAutoMapper = &pEditor->m_Map.m_lImages[pLayer->m_Image]->m_AutoMapper; - + for(int i = 0; i < pAutoMapper->ConfigNamesNum(); ++i) { View.HSplitTop(2.0f, 0, &View); @@ -837,7 +837,7 @@ int CEditor::PopupSelectConfigAutoMapResult() { if(s_AutoMapConfigSelected < 0) return -1; - + int Result = s_AutoMapConfigSelected; s_AutoMapConfigSelected = -1; return Result; diff --git a/src/tools/dilate.cpp b/src/tools/dilate.cpp index eb770a90..55094a5b 100644 --- a/src/tools/dilate.cpp +++ b/src/tools/dilate.cpp @@ -96,7 +96,7 @@ int main(int argc, const char **argv) dbg_msg("Usage", "%s FILE1 [ FILE2... ]", argv[0]); return -1; } - + for(int i = 1; i < argc; i++) DilateFile(argv[i]); return 0; -- cgit 1.4.1 From 4e830a71a1334a6f47ab4b3fb3cf44419a240f25 Mon Sep 17 00:00:00 2001 From: oy Date: Sat, 13 Aug 2011 18:53:41 +0200 Subject: decreased top offset of image add button in the editor. Closes #834 --- src/game/editor/editor.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/game/editor/editor.cpp') diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index b7c1d0cb..0b638aeb 100644 --- a/src/game/editor/editor.cpp +++ b/src/game/editor/editor.cpp @@ -2448,7 +2448,6 @@ void CEditor::RenderImages(CUIRect ToolBox, CUIRect ToolBar, CUIRect View) // new image static int s_NewImageButton = 0; - ToolBox.HSplitTop(10.0f, &Slot, &ToolBox); ToolBox.HSplitTop(12.0f, &Slot, &ToolBox); if(DoButton_Editor(&s_NewImageButton, "Add", 0, &Slot, 0, "Load a new image to use in the map")) InvokeFileDialog(IStorage::TYPE_ALL, FILETYPE_IMG, "Add Image", "Add", "mapres", "", AddImage, this); -- cgit 1.4.1 From c38c632d067702454f1f706eeefcbfaa0043b738 Mon Sep 17 00:00:00 2001 From: oy Date: Sat, 13 Aug 2011 19:22:01 +0200 Subject: fixed multiple popup creation in the editor. Closes #836 --- src/game/editor/editor.cpp | 21 ++++++++++++++------- src/game/editor/editor.h | 2 ++ src/game/editor/popups.cpp | 4 ++++ 3 files changed, 20 insertions(+), 7 deletions(-) (limited to 'src/game/editor/editor.cpp') diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index 0b638aeb..3d655e71 100644 --- a/src/game/editor/editor.cpp +++ b/src/game/editor/editor.cpp @@ -749,25 +749,31 @@ void CEditor::DoToolbar(CUIRect ToolBar) TB_Bottom.HSplitTop(2.5f, 0, &TB_Bottom); // ctrl+o to open - if(Input()->KeyDown('o') && (Input()->KeyPressed(KEY_LCTRL) || Input()->KeyPressed(KEY_RCTRL))) + if(Input()->KeyDown('o') && (Input()->KeyPressed(KEY_LCTRL) || Input()->KeyPressed(KEY_RCTRL)) && m_Dialog == DIALOG_NONE) { if(HasUnsavedData()) { - m_PopupEventType = POPEVENT_LOAD; - m_PopupEventActivated = true; + if(!m_PopupEventWasActivated) + { + m_PopupEventType = POPEVENT_LOAD; + m_PopupEventActivated = true; + } } else InvokeFileDialog(IStorage::TYPE_ALL, FILETYPE_MAP, "Load map", "Load", "maps", "", CallbackOpenMap, this); } // ctrl+s to save - if(Input()->KeyDown('s') && (Input()->KeyPressed(KEY_LCTRL) || Input()->KeyPressed(KEY_RCTRL))) + if(Input()->KeyDown('s') && (Input()->KeyPressed(KEY_LCTRL) || Input()->KeyPressed(KEY_RCTRL)) && m_Dialog == DIALOG_NONE) { if(m_aFileName[0] && m_ValidSaveFilename) { - str_copy(m_aFileSaveName, m_aFileName, sizeof(m_aFileSaveName)); - m_PopupEventType = POPEVENT_SAVE; - m_PopupEventActivated = true; + if(!m_PopupEventWasActivated) + { + str_copy(m_aFileSaveName, m_aFileName, sizeof(m_aFileSaveName)); + m_PopupEventType = POPEVENT_SAVE; + m_PopupEventActivated = true; + } } else InvokeFileDialog(IStorage::TYPE_SAVE, FILETYPE_MAP, "Save map", "Save", "maps", "", CallbackSaveMap, this); @@ -3420,6 +3426,7 @@ void CEditor::Render() static int s_PopupID = 0; UiInvokePopupMenu(&s_PopupID, 0, Width/2.0f-200.0f, Height/2.0f-100.0f, 400.0f, 200.0f, PopupEvent); m_PopupEventActivated = false; + m_PopupEventWasActivated = true; } diff --git a/src/game/editor/editor.h b/src/game/editor/editor.h index db99a78c..bdabd43f 100644 --- a/src/game/editor/editor.h +++ b/src/game/editor/editor.h @@ -486,6 +486,7 @@ public: m_ValidSaveFilename = false; m_PopupEventActivated = false; + m_PopupEventWasActivated = false; m_FileDialogStorageType = 0; m_pFileDialogTitle = 0; @@ -579,6 +580,7 @@ public: int m_PopupEventType; int m_PopupEventActivated; + int m_PopupEventWasActivated; enum { diff --git a/src/game/editor/popups.cpp b/src/game/editor/popups.cpp index a97146aa..c19adb82 100644 --- a/src/game/editor/popups.cpp +++ b/src/game/editor/popups.cpp @@ -684,13 +684,17 @@ int CEditor::PopupEvent(CEditor *pEditor, CUIRect View) } else if(pEditor->m_PopupEventType == POPEVENT_SAVE) pEditor->CallbackSaveMap(pEditor->m_aFileSaveName, IStorage::TYPE_SAVE, pEditor); + pEditor->m_PopupEventWasActivated = false; return 1; } ButtonBar.VSplitRight(30.0f, &ButtonBar, 0); ButtonBar.VSplitRight(110.0f, &ButtonBar, &Label); static int s_AbortButton = 0; if(pEditor->DoButton_Editor(&s_AbortButton, "Abort", 0, &Label, 0, 0)) + { + pEditor->m_PopupEventWasActivated = false; return 1; + } return 0; } -- cgit 1.4.1 From 367bb4b8372dd8c19445c599df3b30ac6aed04d9 Mon Sep 17 00:00:00 2001 From: Alexandre Date: Sun, 14 Aug 2011 16:31:48 +0200 Subject: Map Editor: Envelope Preview --- src/game/editor/editor.cpp | 209 ++++++++++++++++++++++++++++++++++++++++++++- src/game/editor/editor.h | 12 ++- 2 files changed, 219 insertions(+), 2 deletions(-) (limited to 'src/game/editor/editor.cpp') diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index 3d655e71..9280cb5f 100644 --- a/src/game/editor/editor.cpp +++ b/src/game/editor/editor.cpp @@ -1391,6 +1391,180 @@ void CEditor::DoQuadPoint(CQuad *pQuad, int QuadIndex, int V) Graphics()->QuadsDraw(&QuadItem, 1); } +//H-Client +void CEditor::DoQuadEnvelopes(CQuad *q, int Index, int texID) +{ + CEnvelope *pEnvelope = 0x0; + if(q->m_PosEnv >= 0 && q->m_PosEnv < m_Map.m_lEnvelopes.size()) + pEnvelope = m_Map.m_lEnvelopes[q->m_PosEnv]; + if (!pEnvelope) + return; + + //QuadParams + CPoint *pPoints = q->m_aPoints; + + //Draw Lines + Graphics()->TextureSet(-1); + Graphics()->LinesBegin(); + Graphics()->SetColor(80.0f/255, 150.0f/255, 230.f/255, 0.5f); + for(int i = 0; i < pEnvelope->m_lPoints.size()-1; i++) + { + float OffsetX = 0; + float OffsetY = 0; + + OffsetX = fx2f(pEnvelope->m_lPoints[i].m_aValues[0]); + OffsetY = fx2f(pEnvelope->m_lPoints[i].m_aValues[1]); + vec2 pos0 = vec2(fx2f(pPoints[4].x)+OffsetX, fx2f(pPoints[4].y)+OffsetY); + + OffsetX = fx2f(pEnvelope->m_lPoints[i+1].m_aValues[0]); + OffsetY = fx2f(pEnvelope->m_lPoints[i+1].m_aValues[1]); + vec2 pos1 = vec2(fx2f(pPoints[4].x)+OffsetX, fx2f(pPoints[4].y)+OffsetY); + + IGraphics::CLineItem uLine = IGraphics::CLineItem(pos0.x, pos0.y, pos1.x, pos1.y); + Graphics()->LinesDraw(&uLine, 1); + } + Graphics()->SetColor(1.0f, 1.0f, 1.0f, 1.0f); + Graphics()->LinesEnd(); + + //Draw Quads + Graphics()->TextureSet(texID); + Graphics()->QuadsBegin(); + for(int i = 0; i < pEnvelope->m_lPoints.size(); i++) + { + float OffsetX = 0; + float OffsetY = 0; + float Rot = 0; + + //Calc Env Position + OffsetX = fx2f(pEnvelope->m_lPoints[i].m_aValues[0]); + OffsetY = fx2f(pEnvelope->m_lPoints[i].m_aValues[1]); + Rot = fx2f(pEnvelope->m_lPoints[i].m_aValues[2])/360.0f*pi*2; + + //Set Colours + IGraphics::CColorVertex CArray[4] = { + IGraphics::CColorVertex(0, q->m_aColors[0].r, q->m_aColors[0].g, q->m_aColors[0].b, (m_SelectedQuadEnvelope == q->m_PosEnv && m_SelectedEnvelopeChannel == i)?0.65:0.35f), + IGraphics::CColorVertex(1, q->m_aColors[1].r, q->m_aColors[1].g, q->m_aColors[1].b, (m_SelectedQuadEnvelope == q->m_PosEnv && m_SelectedEnvelopeChannel == i)?0.65:0.35f), + IGraphics::CColorVertex(2, q->m_aColors[2].r, q->m_aColors[2].g, q->m_aColors[2].b, (m_SelectedQuadEnvelope == q->m_PosEnv && m_SelectedEnvelopeChannel == i)?0.65:0.35f), + IGraphics::CColorVertex(3, q->m_aColors[3].r, q->m_aColors[3].g, q->m_aColors[3].b, (m_SelectedQuadEnvelope == q->m_PosEnv && m_SelectedEnvelopeChannel == i)?0.65:0.35f)}; + Graphics()->SetColorVertex(CArray, 4); + + //Rotation + if(Rot != 0) + { + static CPoint aRotated[4]; + aRotated[0] = q->m_aPoints[0]; + aRotated[1] = q->m_aPoints[1]; + aRotated[2] = q->m_aPoints[2]; + aRotated[3] = q->m_aPoints[3]; + pPoints = aRotated; + + Rotate(&q->m_aPoints[4], &aRotated[0], Rot); + Rotate(&q->m_aPoints[4], &aRotated[1], Rot); + Rotate(&q->m_aPoints[4], &aRotated[2], Rot); + Rotate(&q->m_aPoints[4], &aRotated[3], Rot); + } + + //Set Texture Coords + Graphics()->QuadsSetSubsetFree( + fx2f(q->m_aTexcoords[0].x), fx2f(q->m_aTexcoords[0].y), + fx2f(q->m_aTexcoords[1].x), fx2f(q->m_aTexcoords[1].y), + fx2f(q->m_aTexcoords[2].x), fx2f(q->m_aTexcoords[2].y), + fx2f(q->m_aTexcoords[3].x), fx2f(q->m_aTexcoords[3].y) + ); + + //Set Quad Coords & Draw + IGraphics::CFreeformItem Freeform( + fx2f(pPoints[0].x)+OffsetX, fx2f(pPoints[0].y)+OffsetY, + fx2f(pPoints[1].x)+OffsetX, fx2f(pPoints[1].y)+OffsetY, + fx2f(pPoints[2].x)+OffsetX, fx2f(pPoints[2].y)+OffsetY, + fx2f(pPoints[3].x)+OffsetX, fx2f(pPoints[3].y)+OffsetY); + Graphics()->QuadsDrawFreeform(&Freeform, 1); + + DoQuadEnvPoint(q, 1, i); + } + Graphics()->QuadsEnd(); + Graphics()->TextureSet(-1); +} + +void CEditor::DoQuadEnvPoint(CQuad *pQuad, int Index, int V) +{ + enum + { + OP_NONE=0, + OP_MOVE_PIVOT, + }; + + // some basic values + static float s_LastWx; + static float s_LastWy; + static int s_Operation = OP_NONE; + float wx = UI()->MouseWorldX(); + float wy = UI()->MouseWorldY(); + CEnvelope *pEnvelope = m_Map.m_lEnvelopes[pQuad->m_PosEnv]; + void *pID = &pEnvelope->m_lPoints[V]; + + // get pivot + float CenterX = fx2f(pQuad->m_aPoints[4].x)+fx2f(pEnvelope->m_lPoints[V].m_aValues[0]); + float CenterY = fx2f(pQuad->m_aPoints[4].y)+fx2f(pEnvelope->m_lPoints[V].m_aValues[1]); + + float dx = (CenterX - wx)/m_WorldZoom; + float dy = (CenterY - wy)/m_WorldZoom; + if(dx*dx+dy*dy < 50) + UI()->SetHotItem(pID); + + if(UI()->ActiveItem() == pID) + { + // check if we only should move pivot + if(s_Operation == OP_MOVE_PIVOT) + { + pEnvelope->m_lPoints[V].m_aValues[0] += f2fx(wx-s_LastWx); + pEnvelope->m_lPoints[V].m_aValues[1] += f2fx(wy-s_LastWy); + } + + s_LastWx = wx; + s_LastWy = wy; + + if(!UI()->MouseButton(0)) + { + m_LockMouse = false; + s_Operation = OP_NONE; + UI()->SetActiveItem(0); + } + + Graphics()->SetColor(1,1,1,1); + } + else if(UI()->HotItem() == pID) + { + ms_pUiGotContext = pID; + + Graphics()->SetColor(1,1,1,1); + //m_pTooltip = ""; + + if(UI()->MouseButton(0)) + { + s_Operation = OP_MOVE_PIVOT; + + m_SelectedEnvelopeChannel = V; + m_SelectedQuadEnvelope = pQuad->m_PosEnv; + + UI()->SetActiveItem(pID); + m_SelectedQuad = Index; + s_LastWx = wx; + s_LastWy = wy; + } + else + { + m_SelectedEnvelopeChannel = -1; + m_SelectedQuadEnvelope = -1; + } + } + else + Graphics()->SetColor(0,1,0,1); + + IGraphics::CQuadItem QuadItem(CenterX, CenterY, 5.0f*m_WorldZoom, 5.0f*m_WorldZoom); + Graphics()->QuadsDraw(&QuadItem, 1); +} + void CEditor::DoMapEditor(CUIRect View, CUIRect ToolBar) { // render all good stuff @@ -1688,6 +1862,8 @@ void CEditor::DoMapEditor(CUIRect View, CUIRect ToolBar) if(pEditLayers[k]->m_Type == LAYERTYPE_QUADS) { CLayerQuads *pLayer = (CLayerQuads *)pEditLayers[k]; + + m_ShowEnvelopePreview = 2; Graphics()->TextureSet(-1); Graphics()->QuadsBegin(); @@ -1846,6 +2022,24 @@ void CEditor::DoMapEditor(CUIRect View, CUIRect ToolBar) Graphics()->LinesEnd(); } + if (!m_ShowPicker && m_ShowTileInfo && m_ShowEnvelopePreview != 0 && GetSelectedLayer(0) && GetSelectedLayer(0)->m_Type == LAYERTYPE_QUADS) + { + GetSelectedGroup()->MapScreen(); + + CLayerQuads *pLayer = (CLayerQuads*)GetSelectedLayer(0); + int texID = -1; + if(pLayer->m_Image >= 0 && pLayer->m_Image < m_Map.m_lImages.size()) + texID = m_Map.m_lImages[pLayer->m_Image]->m_TexID; + + for(int i = 0; i < pLayer->m_lQuads.size(); i++) + { + if ((m_ShowEnvelopePreview == 1 && pLayer->m_lQuads[i].m_PosEnv == m_SelectedEnvelope) || m_ShowEnvelopePreview == 2) + DoQuadEnvelopes(&pLayer->m_lQuads[i], i, texID); + } + + m_ShowEnvelopePreview = 0; + } + Graphics()->MapScreen(UI()->Screen()->x, UI()->Screen()->y, UI()->Screen()->w, UI()->Screen()->h); //UI()->ClipDisable(); } @@ -2991,6 +3185,7 @@ void CEditor::RenderEnvelopeEditor(CUIRect View) m_Map.m_Modified = true; } + m_ShowEnvelopePreview = 1; m_pTooltip = "Press right mouse button to create a new point"; } } @@ -3129,6 +3324,9 @@ void CEditor::RenderEnvelopeEditor(CUIRect View) { if(!UI()->MouseButton(0)) { + m_SelectedQuadEnvelope = -1; + m_SelectedEnvelopeChannel = -1; + UI()->SetActiveItem(0); } else @@ -3154,6 +3352,9 @@ void CEditor::RenderEnvelopeEditor(CUIRect View) else pEnvelope->m_lPoints[i].m_aValues[c] -= f2fx(m_MouseDeltaY*ValueScale); } + + m_SelectedQuadEnvelope = m_SelectedEnvelope; + m_SelectedEnvelopeChannel = i; m_Map.m_Modified = true; } @@ -3176,6 +3377,7 @@ void CEditor::RenderEnvelopeEditor(CUIRect View) m_Map.m_Modified = true; } + m_ShowEnvelopePreview = 1; ColorMod = 100.0f; Graphics()->SetColor(1,0.75f,0.75f,1); m_pTooltip = "Left mouse to drag. Hold ctrl to be more precise. Hold shift to alter time point aswell. Right click to delete."; @@ -3187,7 +3389,10 @@ void CEditor::RenderEnvelopeEditor(CUIRect View) CurrentValue = pEnvelope->m_lPoints[i].m_aValues[c]; } - Graphics()->SetColor(aColors[c].r*ColorMod, aColors[c].g*ColorMod, aColors[c].b*ColorMod, 1.0f); + if (m_SelectedQuadEnvelope == m_SelectedEnvelope && m_SelectedEnvelopeChannel == i) + Graphics()->SetColor(1.0f, 1.0f, 1.0f, 1.0f); + else + Graphics()->SetColor(aColors[c].r*ColorMod, aColors[c].g*ColorMod, aColors[c].b*ColorMod, 1.0f); IGraphics::CQuadItem QuadItem(Final.x, Final.y, Final.w, Final.h); Graphics()->QuadsDrawTL(&QuadItem, 1); } @@ -3503,6 +3708,8 @@ void CEditor::Reset(bool CreateDefault) m_MouseDeltaWy = 0; m_Map.m_Modified = false; + + m_ShowEnvelopePreview = 0; } int CEditor::GetLineDistance() diff --git a/src/game/editor/editor.h b/src/game/editor/editor.h index bdabd43f..2c94f3f2 100644 --- a/src/game/editor/editor.h +++ b/src/game/editor/editor.h @@ -529,6 +529,10 @@ public: m_ShowEnvelopeEditor = 0; + m_ShowEnvelopePreview = 0; + m_SelectedQuadEnvelope = -1; + m_SelectedEnvelopeChannel = -1; + ms_CheckerTexture = 0; ms_BackgroundTexture = 0; ms_CursorTexture = 0; @@ -646,13 +650,16 @@ public: float m_AnimateSpeed; int m_ShowEnvelopeEditor; + int m_ShowEnvelopePreview; //Values: 0-Off|1-Selected Envelope|2-All bool m_ShowPicker; int m_SelectedLayer; int m_SelectedGroup; int m_SelectedQuad; int m_SelectedPoints; - int m_SelectedEnvelope; + int m_SelectedEnvelope; + int m_SelectedEnvelopeChannel; + int m_SelectedQuadEnvelope; int m_SelectedImage; static int ms_CheckerTexture; @@ -721,7 +728,10 @@ public: vec4 ButtonColorMul(const void *pID); + void DoQuadEnvelopes(CQuad *q, int Index, int texID = -1); + void DoQuadEnvPoint(CQuad *pQuad, int Index, int V); void DoQuadPoint(CQuad *pQuad, int QuadIndex, int v); + void DoMapEditor(CUIRect View, CUIRect Toolbar); void DoToolbar(CUIRect Toolbar); void DoQuad(CQuad *pQuad, int Index); -- cgit 1.4.1 From de5eccef3f18b2a3e2fbe746be559d0a7f078d27 Mon Sep 17 00:00:00 2001 From: Alexandre Date: Sun, 14 Aug 2011 21:16:19 +0200 Subject: Fix Stuffs & clean comments --- src/game/editor/editor.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/game/editor/editor.cpp') diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index 9280cb5f..31405892 100644 --- a/src/game/editor/editor.cpp +++ b/src/game/editor/editor.cpp @@ -820,6 +820,7 @@ void CEditor::DoToolbar(CUIRect ToolBar) (Input()->KeyDown('i') && (Input()->KeyPressed(KEY_LCTRL) || Input()->KeyPressed(KEY_RCTRL)))) { m_ShowTileInfo = !m_ShowTileInfo; + m_ShowEnvelopePreview = 0; } TB_Top.VSplitLeft(15.0f, 0, &TB_Top); @@ -1390,8 +1391,7 @@ void CEditor::DoQuadPoint(CQuad *pQuad, int QuadIndex, int V) IGraphics::CQuadItem QuadItem(px, py, 5.0f*m_WorldZoom, 5.0f*m_WorldZoom); Graphics()->QuadsDraw(&QuadItem, 1); } - -//H-Client + void CEditor::DoQuadEnvelopes(CQuad *q, int Index, int texID) { CEnvelope *pEnvelope = 0x0; @@ -1862,8 +1862,9 @@ void CEditor::DoMapEditor(CUIRect View, CUIRect ToolBar) if(pEditLayers[k]->m_Type == LAYERTYPE_QUADS) { CLayerQuads *pLayer = (CLayerQuads *)pEditLayers[k]; - - m_ShowEnvelopePreview = 2; + + if (!m_ShowEnvelopePreview) + m_ShowEnvelopePreview = 2; Graphics()->TextureSet(-1); Graphics()->QuadsBegin(); @@ -3353,7 +3354,8 @@ void CEditor::RenderEnvelopeEditor(CUIRect View) pEnvelope->m_lPoints[i].m_aValues[c] -= f2fx(m_MouseDeltaY*ValueScale); } - m_SelectedQuadEnvelope = m_SelectedEnvelope; + m_SelectedQuadEnvelope = m_SelectedEnvelope; + m_ShowEnvelopePreview = 1; m_SelectedEnvelopeChannel = i; m_Map.m_Modified = true; } -- cgit 1.4.1 From f36cc57bdd4837f6f148e6d83e6a5185b1328b7d Mon Sep 17 00:00:00 2001 From: oy Date: Mon, 15 Aug 2011 20:12:31 +0200 Subject: fixed last commit --- src/game/editor/editor.cpp | 339 ++++++++++++++++++++++++--------------------- src/game/editor/editor.h | 14 +- 2 files changed, 191 insertions(+), 162 deletions(-) (limited to 'src/game/editor/editor.cpp') diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index 31405892..41553808 100644 --- a/src/game/editor/editor.cpp +++ b/src/game/editor/editor.cpp @@ -1391,107 +1391,106 @@ void CEditor::DoQuadPoint(CQuad *pQuad, int QuadIndex, int V) IGraphics::CQuadItem QuadItem(px, py, 5.0f*m_WorldZoom, 5.0f*m_WorldZoom); Graphics()->QuadsDraw(&QuadItem, 1); } - -void CEditor::DoQuadEnvelopes(CQuad *q, int Index, int texID) -{ + +void CEditor::DoQuadEnvelopes(CQuad *pQuad, int Index, int TexID) +{ CEnvelope *pEnvelope = 0x0; - if(q->m_PosEnv >= 0 && q->m_PosEnv < m_Map.m_lEnvelopes.size()) - pEnvelope = m_Map.m_lEnvelopes[q->m_PosEnv]; - if (!pEnvelope) - return; - - //QuadParams - CPoint *pPoints = q->m_aPoints; - - //Draw Lines - Graphics()->TextureSet(-1); - Graphics()->LinesBegin(); - Graphics()->SetColor(80.0f/255, 150.0f/255, 230.f/255, 0.5f); - for(int i = 0; i < pEnvelope->m_lPoints.size()-1; i++) - { - float OffsetX = 0; - float OffsetY = 0; - - OffsetX = fx2f(pEnvelope->m_lPoints[i].m_aValues[0]); - OffsetY = fx2f(pEnvelope->m_lPoints[i].m_aValues[1]); - vec2 pos0 = vec2(fx2f(pPoints[4].x)+OffsetX, fx2f(pPoints[4].y)+OffsetY); - - OffsetX = fx2f(pEnvelope->m_lPoints[i+1].m_aValues[0]); - OffsetY = fx2f(pEnvelope->m_lPoints[i+1].m_aValues[1]); - vec2 pos1 = vec2(fx2f(pPoints[4].x)+OffsetX, fx2f(pPoints[4].y)+OffsetY); - - IGraphics::CLineItem uLine = IGraphics::CLineItem(pos0.x, pos0.y, pos1.x, pos1.y); - Graphics()->LinesDraw(&uLine, 1); - } - Graphics()->SetColor(1.0f, 1.0f, 1.0f, 1.0f); - Graphics()->LinesEnd(); - - //Draw Quads - Graphics()->TextureSet(texID); - Graphics()->QuadsBegin(); - for(int i = 0; i < pEnvelope->m_lPoints.size(); i++) - { - float OffsetX = 0; - float OffsetY = 0; - float Rot = 0; - - //Calc Env Position - OffsetX = fx2f(pEnvelope->m_lPoints[i].m_aValues[0]); - OffsetY = fx2f(pEnvelope->m_lPoints[i].m_aValues[1]); - Rot = fx2f(pEnvelope->m_lPoints[i].m_aValues[2])/360.0f*pi*2; - - //Set Colours - IGraphics::CColorVertex CArray[4] = { - IGraphics::CColorVertex(0, q->m_aColors[0].r, q->m_aColors[0].g, q->m_aColors[0].b, (m_SelectedQuadEnvelope == q->m_PosEnv && m_SelectedEnvelopeChannel == i)?0.65:0.35f), - IGraphics::CColorVertex(1, q->m_aColors[1].r, q->m_aColors[1].g, q->m_aColors[1].b, (m_SelectedQuadEnvelope == q->m_PosEnv && m_SelectedEnvelopeChannel == i)?0.65:0.35f), - IGraphics::CColorVertex(2, q->m_aColors[2].r, q->m_aColors[2].g, q->m_aColors[2].b, (m_SelectedQuadEnvelope == q->m_PosEnv && m_SelectedEnvelopeChannel == i)?0.65:0.35f), - IGraphics::CColorVertex(3, q->m_aColors[3].r, q->m_aColors[3].g, q->m_aColors[3].b, (m_SelectedQuadEnvelope == q->m_PosEnv && m_SelectedEnvelopeChannel == i)?0.65:0.35f)}; - Graphics()->SetColorVertex(CArray, 4); - - //Rotation - if(Rot != 0) - { - static CPoint aRotated[4]; - aRotated[0] = q->m_aPoints[0]; - aRotated[1] = q->m_aPoints[1]; - aRotated[2] = q->m_aPoints[2]; - aRotated[3] = q->m_aPoints[3]; - pPoints = aRotated; - - Rotate(&q->m_aPoints[4], &aRotated[0], Rot); - Rotate(&q->m_aPoints[4], &aRotated[1], Rot); - Rotate(&q->m_aPoints[4], &aRotated[2], Rot); - Rotate(&q->m_aPoints[4], &aRotated[3], Rot); - } - - //Set Texture Coords - Graphics()->QuadsSetSubsetFree( - fx2f(q->m_aTexcoords[0].x), fx2f(q->m_aTexcoords[0].y), - fx2f(q->m_aTexcoords[1].x), fx2f(q->m_aTexcoords[1].y), - fx2f(q->m_aTexcoords[2].x), fx2f(q->m_aTexcoords[2].y), - fx2f(q->m_aTexcoords[3].x), fx2f(q->m_aTexcoords[3].y) - ); - - //Set Quad Coords & Draw - IGraphics::CFreeformItem Freeform( - fx2f(pPoints[0].x)+OffsetX, fx2f(pPoints[0].y)+OffsetY, - fx2f(pPoints[1].x)+OffsetX, fx2f(pPoints[1].y)+OffsetY, - fx2f(pPoints[2].x)+OffsetX, fx2f(pPoints[2].y)+OffsetY, - fx2f(pPoints[3].x)+OffsetX, fx2f(pPoints[3].y)+OffsetY); - Graphics()->QuadsDrawFreeform(&Freeform, 1); - - DoQuadEnvPoint(q, 1, i); - } - Graphics()->QuadsEnd(); - Graphics()->TextureSet(-1); -} - -void CEditor::DoQuadEnvPoint(CQuad *pQuad, int Index, int V) + if(pQuad->m_PosEnv >= 0 && pQuad->m_PosEnv < m_Map.m_lEnvelopes.size()) + pEnvelope = m_Map.m_lEnvelopes[pQuad->m_PosEnv]; + if (!pEnvelope) + return; + + //QuadParams + CPoint *pPoints = pQuad->m_aPoints; + + //Draw Lines + Graphics()->TextureSet(-1); + Graphics()->LinesBegin(); + Graphics()->SetColor(80.0f/255, 150.0f/255, 230.f/255, 0.5f); + for(int i = 0; i < pEnvelope->m_lPoints.size()-1; i++) + { + float OffsetX = fx2f(pEnvelope->m_lPoints[i].m_aValues[0]); + float OffsetY = fx2f(pEnvelope->m_lPoints[i].m_aValues[1]); + vec2 Pos0 = vec2(fx2f(pPoints[4].x)+OffsetX, fx2f(pPoints[4].y)+OffsetY); + + OffsetX = fx2f(pEnvelope->m_lPoints[i+1].m_aValues[0]); + OffsetY = fx2f(pEnvelope->m_lPoints[i+1].m_aValues[1]); + vec2 Pos1 = vec2(fx2f(pPoints[4].x)+OffsetX, fx2f(pPoints[4].y)+OffsetY); + + IGraphics::CLineItem Line = IGraphics::CLineItem(Pos0.x, Pos0.y, Pos1.x, Pos1.y); + Graphics()->LinesDraw(&Line, 1); + } + Graphics()->SetColor(1.0f, 1.0f, 1.0f, 1.0f); + Graphics()->LinesEnd(); + + //Draw Quads + for(int i = 0; i < pEnvelope->m_lPoints.size(); i++) + { + Graphics()->TextureSet(TexID); + Graphics()->QuadsBegin(); + + //Calc Env Position + float OffsetX = fx2f(pEnvelope->m_lPoints[i].m_aValues[0]); + float OffsetY = fx2f(pEnvelope->m_lPoints[i].m_aValues[1]); + float Rot = fx2f(pEnvelope->m_lPoints[i].m_aValues[2])/360.0f*pi*2; + + //Set Colours + float Alpha = (m_SelectedQuadEnvelope == pQuad->m_PosEnv && m_SelectedEnvelopePoint == i) ? 0.65f : 0.35f; + IGraphics::CColorVertex aArray[4] = { + IGraphics::CColorVertex(0, pQuad->m_aColors[0].r, pQuad->m_aColors[0].g, pQuad->m_aColors[0].b, Alpha), + IGraphics::CColorVertex(1, pQuad->m_aColors[1].r, pQuad->m_aColors[1].g, pQuad->m_aColors[1].b, Alpha), + IGraphics::CColorVertex(2, pQuad->m_aColors[2].r, pQuad->m_aColors[2].g, pQuad->m_aColors[2].b, Alpha), + IGraphics::CColorVertex(3, pQuad->m_aColors[3].r, pQuad->m_aColors[3].g, pQuad->m_aColors[3].b, Alpha)}; + Graphics()->SetColorVertex(aArray, 4); + + //Rotation + if(Rot != 0) + { + static CPoint aRotated[4]; + aRotated[0] = pQuad->m_aPoints[0]; + aRotated[1] = pQuad->m_aPoints[1]; + aRotated[2] = pQuad->m_aPoints[2]; + aRotated[3] = pQuad->m_aPoints[3]; + pPoints = aRotated; + + Rotate(&pQuad->m_aPoints[4], &aRotated[0], Rot); + Rotate(&pQuad->m_aPoints[4], &aRotated[1], Rot); + Rotate(&pQuad->m_aPoints[4], &aRotated[2], Rot); + Rotate(&pQuad->m_aPoints[4], &aRotated[3], Rot); + } + + //Set Texture Coords + Graphics()->QuadsSetSubsetFree( + fx2f(pQuad->m_aTexcoords[0].x), fx2f(pQuad->m_aTexcoords[0].y), + fx2f(pQuad->m_aTexcoords[1].x), fx2f(pQuad->m_aTexcoords[1].y), + fx2f(pQuad->m_aTexcoords[2].x), fx2f(pQuad->m_aTexcoords[2].y), + fx2f(pQuad->m_aTexcoords[3].x), fx2f(pQuad->m_aTexcoords[3].y) + ); + + //Set Quad Coords & Draw + IGraphics::CFreeformItem Freeform( + fx2f(pPoints[0].x)+OffsetX, fx2f(pPoints[0].y)+OffsetY, + fx2f(pPoints[1].x)+OffsetX, fx2f(pPoints[1].y)+OffsetY, + fx2f(pPoints[2].x)+OffsetX, fx2f(pPoints[2].y)+OffsetY, + fx2f(pPoints[3].x)+OffsetX, fx2f(pPoints[3].y)+OffsetY); + Graphics()->QuadsDrawFreeform(&Freeform, 1); + + Graphics()->QuadsEnd(); + + Graphics()->TextureSet(-1); + Graphics()->QuadsBegin(); + DoQuadEnvPoint(pQuad, Index, i); + Graphics()->QuadsEnd(); + } +} + +void CEditor::DoQuadEnvPoint(CQuad *pQuad, int QIndex, int PIndex) { enum { OP_NONE=0, - OP_MOVE_PIVOT, + OP_MOVE, + OP_ROTATE, }; // some basic values @@ -1499,13 +1498,13 @@ void CEditor::DoQuadEnvPoint(CQuad *pQuad, int Index, int V) static float s_LastWy; static int s_Operation = OP_NONE; float wx = UI()->MouseWorldX(); - float wy = UI()->MouseWorldY(); - CEnvelope *pEnvelope = m_Map.m_lEnvelopes[pQuad->m_PosEnv]; - void *pID = &pEnvelope->m_lPoints[V]; + float wy = UI()->MouseWorldY(); + CEnvelope *pEnvelope = m_Map.m_lEnvelopes[pQuad->m_PosEnv]; + void *pID = &pEnvelope->m_lPoints[PIndex]; // get pivot - float CenterX = fx2f(pQuad->m_aPoints[4].x)+fx2f(pEnvelope->m_lPoints[V].m_aValues[0]); - float CenterY = fx2f(pQuad->m_aPoints[4].y)+fx2f(pEnvelope->m_lPoints[V].m_aValues[1]); + float CenterX = fx2f(pQuad->m_aPoints[4].x)+fx2f(pEnvelope->m_lPoints[PIndex].m_aValues[0]); + float CenterY = fx2f(pQuad->m_aPoints[4].y)+fx2f(pEnvelope->m_lPoints[PIndex].m_aValues[1]); float dx = (CenterX - wx)/m_WorldZoom; float dy = (CenterY - wy)/m_WorldZoom; @@ -1514,52 +1513,82 @@ void CEditor::DoQuadEnvPoint(CQuad *pQuad, int Index, int V) if(UI()->ActiveItem() == pID) { - // check if we only should move pivot - if(s_Operation == OP_MOVE_PIVOT) + if(s_Operation == OP_MOVE) { - pEnvelope->m_lPoints[V].m_aValues[0] += f2fx(wx-s_LastWx); - pEnvelope->m_lPoints[V].m_aValues[1] += f2fx(wy-s_LastWy); + if(m_GridActive) + { + int LineDistance = GetLineDistance(); + + float x = 0.0f; + float y = 0.0f; + if(wx >= 0) + x = (int)((wx+(LineDistance/2)*m_GridFactor)/(LineDistance*m_GridFactor)) * (LineDistance*m_GridFactor); + else + x = (int)((wx-(LineDistance/2)*m_GridFactor)/(LineDistance*m_GridFactor)) * (LineDistance*m_GridFactor); + if(wy >= 0) + y = (int)((wy+(LineDistance/2)*m_GridFactor)/(LineDistance*m_GridFactor)) * (LineDistance*m_GridFactor); + else + y = (int)((wy-(LineDistance/2)*m_GridFactor)/(LineDistance*m_GridFactor)) * (LineDistance*m_GridFactor); + + pEnvelope->m_lPoints[PIndex].m_aValues[0] = f2fx(x); + pEnvelope->m_lPoints[PIndex].m_aValues[1] = f2fx(y); + } + else + { + pEnvelope->m_lPoints[PIndex].m_aValues[0] += f2fx(wx-s_LastWx); + pEnvelope->m_lPoints[PIndex].m_aValues[1] += f2fx(wy-s_LastWy); + } } + else if(s_Operation == OP_ROTATE) + pEnvelope->m_lPoints[PIndex].m_aValues[2] += 10*m_MouseDeltaX; s_LastWx = wx; s_LastWy = wy; - if(!UI()->MouseButton(0)) - { - m_LockMouse = false; - s_Operation = OP_NONE; - UI()->SetActiveItem(0); + if(!UI()->MouseButton(0)) + { + m_LockMouse = false; + s_Operation = OP_NONE; + UI()->SetActiveItem(0); } - Graphics()->SetColor(1,1,1,1); + Graphics()->SetColor(1.0f, 1.0f, 1.0f, 1.0f); } else if(UI()->HotItem() == pID) { ms_pUiGotContext = pID; - Graphics()->SetColor(1,1,1,1); - //m_pTooltip = ""; + Graphics()->SetColor(1.0f, 1.0f, 1.0f, 1.0f); + m_pTooltip = "Left mouse button to move. Hold ctrl to rotate."; if(UI()->MouseButton(0)) { - s_Operation = OP_MOVE_PIVOT; - - m_SelectedEnvelopeChannel = V; - m_SelectedQuadEnvelope = pQuad->m_PosEnv; + if(Input()->KeyPressed(KEY_LCTRL) || Input()->KeyPressed(KEY_RCTRL)) + { + m_LockMouse = true; + s_Operation = OP_ROTATE; + } + else + s_Operation = OP_MOVE; + + m_SelectedEnvelopePoint = PIndex; + m_SelectedQuadEnvelope = pQuad->m_PosEnv; UI()->SetActiveItem(pID); - m_SelectedQuad = Index; + if(m_SelectedQuad != QIndex) + m_SelectedPoints = 0; + m_SelectedQuad = QIndex; s_LastWx = wx; s_LastWy = wy; - } - else - { - m_SelectedEnvelopeChannel = -1; - m_SelectedQuadEnvelope = -1; + } + else + { + m_SelectedEnvelopePoint = -1; + m_SelectedQuadEnvelope = -1; } } - else - Graphics()->SetColor(0,1,0,1); + else + Graphics()->SetColor(0.0f, 1.0f, 0.0f, 1.0f); IGraphics::CQuadItem QuadItem(CenterX, CenterY, 5.0f*m_WorldZoom, 5.0f*m_WorldZoom); Graphics()->QuadsDraw(&QuadItem, 1); @@ -1863,8 +1892,8 @@ void CEditor::DoMapEditor(CUIRect View, CUIRect ToolBar) { CLayerQuads *pLayer = (CLayerQuads *)pEditLayers[k]; - if (!m_ShowEnvelopePreview) - m_ShowEnvelopePreview = 2; + if(!m_ShowEnvelopePreview) + m_ShowEnvelopePreview = 2; Graphics()->TextureSet(-1); Graphics()->QuadsBegin(); @@ -2023,22 +2052,22 @@ void CEditor::DoMapEditor(CUIRect View, CUIRect ToolBar) Graphics()->LinesEnd(); } - if (!m_ShowPicker && m_ShowTileInfo && m_ShowEnvelopePreview != 0 && GetSelectedLayer(0) && GetSelectedLayer(0)->m_Type == LAYERTYPE_QUADS) - { - GetSelectedGroup()->MapScreen(); - - CLayerQuads *pLayer = (CLayerQuads*)GetSelectedLayer(0); - int texID = -1; - if(pLayer->m_Image >= 0 && pLayer->m_Image < m_Map.m_lImages.size()) - texID = m_Map.m_lImages[pLayer->m_Image]->m_TexID; - - for(int i = 0; i < pLayer->m_lQuads.size(); i++) - { - if ((m_ShowEnvelopePreview == 1 && pLayer->m_lQuads[i].m_PosEnv == m_SelectedEnvelope) || m_ShowEnvelopePreview == 2) - DoQuadEnvelopes(&pLayer->m_lQuads[i], i, texID); - } - - m_ShowEnvelopePreview = 0; + if (!m_ShowPicker && m_ShowTileInfo && m_ShowEnvelopePreview != 0 && GetSelectedLayer(0) && GetSelectedLayer(0)->m_Type == LAYERTYPE_QUADS) + { + GetSelectedGroup()->MapScreen(); + + CLayerQuads *pLayer = (CLayerQuads*)GetSelectedLayer(0); + int TexID = -1; + if(pLayer->m_Image >= 0 && pLayer->m_Image < m_Map.m_lImages.size()) + TexID = m_Map.m_lImages[pLayer->m_Image]->m_TexID; + + for(int i = 0; i < pLayer->m_lQuads.size(); i++) + { + if((m_ShowEnvelopePreview == 1 && pLayer->m_lQuads[i].m_PosEnv == m_SelectedEnvelope) || m_ShowEnvelopePreview == 2) + DoQuadEnvelopes(&pLayer->m_lQuads[i], i, TexID); + } + + m_ShowEnvelopePreview = 0; } Graphics()->MapScreen(UI()->Screen()->x, UI()->Screen()->y, UI()->Screen()->w, UI()->Screen()->h); @@ -3186,7 +3215,7 @@ void CEditor::RenderEnvelopeEditor(CUIRect View) m_Map.m_Modified = true; } - m_ShowEnvelopePreview = 1; + m_ShowEnvelopePreview = 1; m_pTooltip = "Press right mouse button to create a new point"; } } @@ -3325,8 +3354,8 @@ void CEditor::RenderEnvelopeEditor(CUIRect View) { if(!UI()->MouseButton(0)) { - m_SelectedQuadEnvelope = -1; - m_SelectedEnvelopeChannel = -1; + m_SelectedQuadEnvelope = -1; + m_SelectedEnvelopePoint = -1; UI()->SetActiveItem(0); } @@ -3353,10 +3382,10 @@ void CEditor::RenderEnvelopeEditor(CUIRect View) else pEnvelope->m_lPoints[i].m_aValues[c] -= f2fx(m_MouseDeltaY*ValueScale); } - - m_SelectedQuadEnvelope = m_SelectedEnvelope; - m_ShowEnvelopePreview = 1; - m_SelectedEnvelopeChannel = i; + + m_SelectedQuadEnvelope = m_SelectedEnvelope; + m_ShowEnvelopePreview = 1; + m_SelectedEnvelopePoint = i; m_Map.m_Modified = true; } @@ -3379,7 +3408,7 @@ void CEditor::RenderEnvelopeEditor(CUIRect View) m_Map.m_Modified = true; } - m_ShowEnvelopePreview = 1; + m_ShowEnvelopePreview = 1; ColorMod = 100.0f; Graphics()->SetColor(1,0.75f,0.75f,1); m_pTooltip = "Left mouse to drag. Hold ctrl to be more precise. Hold shift to alter time point aswell. Right click to delete."; @@ -3391,10 +3420,10 @@ void CEditor::RenderEnvelopeEditor(CUIRect View) CurrentValue = pEnvelope->m_lPoints[i].m_aValues[c]; } - if (m_SelectedQuadEnvelope == m_SelectedEnvelope && m_SelectedEnvelopeChannel == i) - Graphics()->SetColor(1.0f, 1.0f, 1.0f, 1.0f); - else - Graphics()->SetColor(aColors[c].r*ColorMod, aColors[c].g*ColorMod, aColors[c].b*ColorMod, 1.0f); + if (m_SelectedQuadEnvelope == m_SelectedEnvelope && m_SelectedEnvelopePoint == i) + Graphics()->SetColor(1.0f, 1.0f, 1.0f, 1.0f); + else + Graphics()->SetColor(aColors[c].r*ColorMod, aColors[c].g*ColorMod, aColors[c].b*ColorMod, 1.0f); IGraphics::CQuadItem QuadItem(Final.x, Final.y, Final.w, Final.h); Graphics()->QuadsDrawTL(&QuadItem, 1); } diff --git a/src/game/editor/editor.h b/src/game/editor/editor.h index 2c94f3f2..1f09b0bc 100644 --- a/src/game/editor/editor.h +++ b/src/game/editor/editor.h @@ -529,9 +529,9 @@ public: m_ShowEnvelopeEditor = 0; - m_ShowEnvelopePreview = 0; - m_SelectedQuadEnvelope = -1; - m_SelectedEnvelopeChannel = -1; + m_ShowEnvelopePreview = 0; + m_SelectedQuadEnvelope = -1; + m_SelectedEnvelopePoint = -1; ms_CheckerTexture = 0; ms_BackgroundTexture = 0; @@ -657,8 +657,8 @@ public: int m_SelectedGroup; int m_SelectedQuad; int m_SelectedPoints; - int m_SelectedEnvelope; - int m_SelectedEnvelopeChannel; + int m_SelectedEnvelope; + int m_SelectedEnvelopePoint; int m_SelectedQuadEnvelope; int m_SelectedImage; @@ -728,8 +728,8 @@ public: vec4 ButtonColorMul(const void *pID); - void DoQuadEnvelopes(CQuad *q, int Index, int texID = -1); - void DoQuadEnvPoint(CQuad *pQuad, int Index, int V); + void DoQuadEnvelopes(CQuad *pQuad, int Index, int TexID = -1); + void DoQuadEnvPoint(CQuad *pQuad, int QIndex, int pIndex); void DoQuadPoint(CQuad *pQuad, int QuadIndex, int v); void DoMapEditor(CUIRect View, CUIRect Toolbar); -- cgit 1.4.1 From 2708256186b7f568e6ce6c34e161bf0d2d349096 Mon Sep 17 00:00:00 2001 From: oy Date: Tue, 16 Aug 2011 21:35:00 +0200 Subject: fixed quad selection via envelope preview --- src/game/editor/editor.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/game/editor/editor.cpp') diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index 41553808..2c3aa550 100644 --- a/src/game/editor/editor.cpp +++ b/src/game/editor/editor.cpp @@ -1501,6 +1501,7 @@ void CEditor::DoQuadEnvPoint(CQuad *pQuad, int QIndex, int PIndex) float wy = UI()->MouseWorldY(); CEnvelope *pEnvelope = m_Map.m_lEnvelopes[pQuad->m_PosEnv]; void *pID = &pEnvelope->m_lPoints[PIndex]; + static int s_ActQIndex = -1; // get pivot float CenterX = fx2f(pQuad->m_aPoints[4].x)+fx2f(pEnvelope->m_lPoints[PIndex].m_aValues[0]); @@ -1508,10 +1509,13 @@ void CEditor::DoQuadEnvPoint(CQuad *pQuad, int QIndex, int PIndex) float dx = (CenterX - wx)/m_WorldZoom; float dy = (CenterY - wy)/m_WorldZoom; - if(dx*dx+dy*dy < 50) + if(dx*dx+dy*dy < 50.0f && UI()->ActiveItem() == 0) + { UI()->SetHotItem(pID); + s_ActQIndex = QIndex; + } - if(UI()->ActiveItem() == pID) + if(UI()->ActiveItem() == pID && s_ActQIndex == QIndex) { if(s_Operation == OP_MOVE) { @@ -1554,7 +1558,7 @@ void CEditor::DoQuadEnvPoint(CQuad *pQuad, int QIndex, int PIndex) Graphics()->SetColor(1.0f, 1.0f, 1.0f, 1.0f); } - else if(UI()->HotItem() == pID) + else if(UI()->HotItem() == pID && s_ActQIndex == QIndex) { ms_pUiGotContext = pID; -- cgit 1.4.1 From 2ceb0fde91b53bff6c6d46bc70c9b6f876a9fc90 Mon Sep 17 00:00:00 2001 From: SushiTee Date: Tue, 16 Aug 2011 22:16:48 +0200 Subject: fixed editor zooming if gui is not active --- src/game/editor/editor.cpp | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'src/game/editor/editor.cpp') diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index 2c3aa550..fe6e963c 100644 --- a/src/game/editor/editor.cpp +++ b/src/game/editor/editor.cpp @@ -828,12 +828,12 @@ void CEditor::DoToolbar(CUIRect ToolBar) // zoom group TB_Top.VSplitLeft(30.0f, &Button, &TB_Top); static int s_ZoomOutButton = 0; - if(DoButton_Ex(&s_ZoomOutButton, "ZO", 0, &Button, 0, "[NumPad-] Zoom out", CUI::CORNER_L) || Input()->KeyDown(KEY_KP_MINUS)) + if(DoButton_Ex(&s_ZoomOutButton, "ZO", 0, &Button, 0, "[NumPad-] Zoom out", CUI::CORNER_L)) m_ZoomLevel += 50; TB_Top.VSplitLeft(30.0f, &Button, &TB_Top); static int s_ZoomNormalButton = 0; - if(DoButton_Ex(&s_ZoomNormalButton, "1:1", 0, &Button, 0, "[NumPad*] Zoom to normal and remove editor offset", 0) || Input()->KeyDown(KEY_KP_MULTIPLY)) + if(DoButton_Ex(&s_ZoomNormalButton, "1:1", 0, &Button, 0, "[NumPad*] Zoom to normal and remove editor offset", 0)) { m_EditorOffsetX = 0; m_EditorOffsetY = 0; @@ -842,7 +842,7 @@ void CEditor::DoToolbar(CUIRect ToolBar) TB_Top.VSplitLeft(30.0f, &Button, &TB_Top); static int s_ZoomInButton = 0; - if(DoButton_Ex(&s_ZoomInButton, "ZI", 0, &Button, 0, "[NumPad+] Zoom in", CUI::CORNER_R) || Input()->KeyDown(KEY_KP_PLUS)) + if(DoButton_Ex(&s_ZoomInButton, "ZI", 0, &Button, 0, "[NumPad+] Zoom in", CUI::CORNER_R)) m_ZoomLevel -= 50; TB_Top.VSplitLeft(10.0f, 0, &TB_Top); @@ -866,8 +866,6 @@ void CEditor::DoToolbar(CUIRect ToolBar) m_AnimateSpeed -= 0.5f; } - m_WorldZoom = m_ZoomLevel/100.0f; - TB_Top.VSplitLeft(10.0f, &Button, &TB_Top); @@ -3598,7 +3596,17 @@ void CEditor::Render() if(m_Mode == MODE_LAYERS) DoMapEditor(View, ToolBar); - // do the scrolling + // do zooming + if(Input()->KeyDown(KEY_KP_MINUS)) + m_ZoomLevel += 50; + if(Input()->KeyDown(KEY_KP_PLUS)) + m_ZoomLevel -= 50; + if(Input()->KeyDown(KEY_KP_MULTIPLY)) + { + m_EditorOffsetX = 0; + m_EditorOffsetY = 0; + m_ZoomLevel = 100; + } if(m_Dialog == DIALOG_NONE && UI()->MouseInside(&View)) { if(Input()->KeyPresses(KEY_MOUSE_WHEEL_UP)) @@ -3606,9 +3614,9 @@ void CEditor::Render() if(Input()->KeyPresses(KEY_MOUSE_WHEEL_DOWN)) m_ZoomLevel += 20; - - m_ZoomLevel = clamp(m_ZoomLevel, 50, 2000); } + m_ZoomLevel = clamp(m_ZoomLevel, 50, 2000); + m_WorldZoom = m_ZoomLevel/100.0f; if(m_GuiActive) { -- cgit 1.4.1 From 48d21b61a2a1b32ba0e39b411311947693ecea47 Mon Sep 17 00:00:00 2001 From: SushiTee Date: Wed, 9 Nov 2011 16:06:17 +0100 Subject: fixed links between tile layer color envelopes when deleting envelopes --- src/game/editor/editor.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/game/editor/editor.cpp') diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index fe6e963c..75f9476c 100644 --- a/src/game/editor/editor.cpp +++ b/src/game/editor/editor.cpp @@ -3798,6 +3798,14 @@ void CEditorMap::DeleteEnvelope(int Index) Layer->m_lQuads[k].m_ColorEnv--; } } + else if(m_lGroups[i]->m_lLayers[j]->m_Type == LAYERTYPE_TILES) + { + CLayerTiles *Layer = static_cast(m_lGroups[i]->m_lLayers[j]); + if(Layer->m_ColorEnv == Index) + Layer->m_ColorEnv = -1; + if(Layer->m_ColorEnv > Index) + Layer->m_ColorEnv--; + } m_lEnvelopes.remove_index(Index); } -- cgit 1.4.1 From c22b6c4b4f75578525cafda557ed1344bec6eec8 Mon Sep 17 00:00:00 2001 From: SushiTee Date: Sat, 26 Nov 2011 01:44:24 +0100 Subject: fixed selecting of quad points --- src/game/editor/editor.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/game/editor/editor.cpp') diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index 75f9476c..6fc88943 100644 --- a/src/game/editor/editor.cpp +++ b/src/game/editor/editor.cpp @@ -1364,6 +1364,7 @@ void CEditor::DoQuadPoint(CQuad *pQuad, int QuadIndex, int V) m_SelectedPoints |= 1< Date: Tue, 29 Nov 2011 22:15:27 +0100 Subject: renamed a variable --- src/game/editor/editor.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'src/game/editor/editor.cpp') diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index 6fc88943..4f4096a9 100644 --- a/src/game/editor/editor.cpp +++ b/src/game/editor/editor.cpp @@ -3786,26 +3786,26 @@ void CEditorMap::DeleteEnvelope(int Index) for(int j = 0; j < m_lGroups[i]->m_lLayers.size(); ++j) if(m_lGroups[i]->m_lLayers[j]->m_Type == LAYERTYPE_QUADS) { - CLayerQuads *Layer = static_cast(m_lGroups[i]->m_lLayers[j]); - for(int k = 0; k < Layer->m_lQuads.size(); ++k) + CLayerQuads *pLayer = static_cast(m_lGroups[i]->m_lLayers[j]); + for(int k = 0; k < pLayer->m_lQuads.size(); ++k) { - if(Layer->m_lQuads[k].m_PosEnv == Index) - Layer->m_lQuads[k].m_PosEnv = -1; - else if(Layer->m_lQuads[k].m_PosEnv > Index) - Layer->m_lQuads[k].m_PosEnv--; - if(Layer->m_lQuads[k].m_ColorEnv == Index) - Layer->m_lQuads[k].m_ColorEnv = -1; - else if(Layer->m_lQuads[k].m_ColorEnv > Index) - Layer->m_lQuads[k].m_ColorEnv--; + if(pLayer->m_lQuads[k].m_PosEnv == Index) + pLayer->m_lQuads[k].m_PosEnv = -1; + else if(pLayer->m_lQuads[k].m_PosEnv > Index) + pLayer->m_lQuads[k].m_PosEnv--; + if(pLayer->m_lQuads[k].m_ColorEnv == Index) + pLayer->m_lQuads[k].m_ColorEnv = -1; + else if(pLayer->m_lQuads[k].m_ColorEnv > Index) + pLayer->m_lQuads[k].m_ColorEnv--; } } else if(m_lGroups[i]->m_lLayers[j]->m_Type == LAYERTYPE_TILES) { - CLayerTiles *Layer = static_cast(m_lGroups[i]->m_lLayers[j]); - if(Layer->m_ColorEnv == Index) - Layer->m_ColorEnv = -1; - if(Layer->m_ColorEnv > Index) - Layer->m_ColorEnv--; + CLayerTiles *pLayer = static_cast(m_lGroups[i]->m_lLayers[j]); + if(pLayer->m_ColorEnv == Index) + pLayer->m_ColorEnv = -1; + if(pLayer->m_ColorEnv > Index) + pLayer->m_ColorEnv--; } m_lEnvelopes.remove_index(Index); -- cgit 1.4.1 From 9a03989e84c8d2719801889738c6af68864aba10 Mon Sep 17 00:00:00 2001 From: oy Date: Sun, 4 Dec 2011 14:34:27 +0100 Subject: added "Make an option for each envelope: (a) synchronized (b) starting at join" by Choupom --- src/game/client/components/maplayers.cpp | 13 +++++++++---- src/game/editor/editor.cpp | 11 +++++++++++ src/game/editor/editor.h | 2 ++ src/game/editor/io.cpp | 5 ++++- src/game/mapitems.h | 8 +++++++- 5 files changed, 33 insertions(+), 6 deletions(-) (limited to 'src/game/editor/editor.cpp') diff --git a/src/game/client/components/maplayers.cpp b/src/game/client/components/maplayers.cpp index 48f11f26..a1e629a6 100644 --- a/src/game/client/components/maplayers.cpp +++ b/src/game/client/components/maplayers.cpp @@ -99,10 +99,15 @@ void CMapLayers::EnvelopeEval(float TimeOffset, int Env, float *pChannels, void } else { - if(pThis->m_pClient->m_Snap.m_pGameInfoObj) - Time = mix((pThis->Client()->PrevGameTick()-pThis->m_pClient->m_Snap.m_pGameInfoObj->m_RoundStartTick) / (float)pThis->Client()->GameTickSpeed(), - (pThis->Client()->GameTick()-pThis->m_pClient->m_Snap.m_pGameInfoObj->m_RoundStartTick) / (float)pThis->Client()->GameTickSpeed(), - pThis->Client()->IntraGameTick()); + if(pItem->m_Version < 2 || pItem->m_Synchronized) + { + if(pThis->m_pClient->m_Snap.m_pGameInfoObj) + Time = mix((pThis->Client()->PrevGameTick()-pThis->m_pClient->m_Snap.m_pGameInfoObj->m_RoundStartTick) / (float)pThis->Client()->GameTickSpeed(), + (pThis->Client()->GameTick()-pThis->m_pClient->m_Snap.m_pGameInfoObj->m_RoundStartTick) / (float)pThis->Client()->GameTickSpeed(), + pThis->Client()->IntraGameTick()); + } + else + Time = pThis->Client()->LocalTime(); pThis->RenderTools()->RenderEvalEnvelope(pPoints+pItem->m_StartPoint, pItem->m_NumPoints, 4, Time+TimeOffset, pChannels); } } diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index 4f4096a9..d2a00d0d 100644 --- a/src/game/editor/editor.cpp +++ b/src/game/editor/editor.cpp @@ -3179,6 +3179,17 @@ void CEditor::RenderEnvelopeEditor(CUIRect View) if(DoButton_Editor(&s_aChannelButtons[i], s_paNames[pEnvelope->m_Channels-3][i], s_ActiveChannels&Bit, &Button, 0, paDescriptions[pEnvelope->m_Channels-3][i])) s_ActiveChannels ^= Bit; } + + // sync checkbox + ToolBar.VSplitLeft(15.0f, &Button, &ToolBar); + ToolBar.VSplitLeft(12.0f, &Button, &ToolBar); + static int s_SyncButton; + if(DoButton_Editor(&s_SyncButton, pEnvelope->m_Synchronized?"X":"", 0, &Button, 0, "Enable envelope synchronization between clients")) + pEnvelope->m_Synchronized = !pEnvelope->m_Synchronized; + + ToolBar.VSplitLeft(4.0f, &Button, &ToolBar); + ToolBar.VSplitLeft(80.0f, &Button, &ToolBar); + UI()->DoLabel(&Button, "Synchronized", 10.0f, -1, -1); } float EndTime = pEnvelope->EndTime(); diff --git a/src/game/editor/editor.h b/src/game/editor/editor.h index 1f09b0bc..f5d43dae 100644 --- a/src/game/editor/editor.h +++ b/src/game/editor/editor.h @@ -51,6 +51,7 @@ public: array m_lPoints; char m_aName[32]; float m_Bottom, m_Top; + bool m_Synchronized; CEnvelope(int Chan) { @@ -58,6 +59,7 @@ public: m_aName[0] = 0; m_Bottom = 0; m_Top = 0; + m_Synchronized = true; } void Resort() diff --git a/src/game/editor/io.cpp b/src/game/editor/io.cpp index 68330f03..aec7231b 100644 --- a/src/game/editor/io.cpp +++ b/src/game/editor/io.cpp @@ -342,10 +342,11 @@ int CEditorMap::Save(class IStorage *pStorage, const char *pFileName) for(int e = 0; e < m_lEnvelopes.size(); e++) { CMapItemEnvelope Item; - Item.m_Version = 1; + Item.m_Version = CMapItemEnvelope::CURRENT_VERSION; Item.m_Channels = m_lEnvelopes[e]->m_Channels; Item.m_StartPoint = PointCount; Item.m_NumPoints = m_lEnvelopes[e]->m_lPoints.size(); + Item.m_Synchronized = m_lEnvelopes[e]->m_Synchronized; StrToInts(Item.m_aName, sizeof(Item.m_aName)/sizeof(int), m_lEnvelopes[e]->m_aName); df.AddItem(MAPITEMTYPE_ENVELOPE, e, sizeof(Item), &Item); @@ -601,6 +602,8 @@ int CEditorMap::Load(class IStorage *pStorage, const char *pFileName, int Storag if(pItem->m_aName[0] != -1) // compatibility with old maps IntsToStr(pItem->m_aName, sizeof(pItem->m_aName)/sizeof(int), pEnv->m_aName); m_lEnvelopes.add(pEnv); + if(pItem->m_Version >= 2) + pEnv->m_Synchronized = pItem->m_Synchronized; } } } diff --git a/src/game/mapitems.h b/src/game/mapitems.h index 43005f75..bb2f4d19 100644 --- a/src/game/mapitems.h +++ b/src/game/mapitems.h @@ -178,7 +178,7 @@ struct CEnvPoint bool operator<(const CEnvPoint &Other) { return m_Time < Other.m_Time; } } ; -struct CMapItemEnvelope +struct CMapItemEnvelope_v1 { int m_Version; int m_Channels; @@ -187,4 +187,10 @@ struct CMapItemEnvelope int m_aName[8]; } ; +struct CMapItemEnvelope : public CMapItemEnvelope_v1 +{ + enum { CURRENT_VERSION=2 }; + int m_Synchronized; +}; + #endif -- cgit 1.4.1 From 1efb494169891ce32cf0ac9a69c1a397259d9ae6 Mon Sep 17 00:00:00 2001 From: Choupom Date: Sun, 4 Dec 2011 18:11:56 +0100 Subject: fixed #791 Ability to disable the magnetic behaviour of the grid --- src/game/editor/editor.cpp | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) (limited to 'src/game/editor/editor.cpp') diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index d2a00d0d..17b45bf2 100644 --- a/src/game/editor/editor.cpp +++ b/src/game/editor/editor.cpp @@ -1051,6 +1051,12 @@ void CEditor::DoQuad(CQuad *q, int Index) if(dx*dx+dy*dy < 50) UI()->SetHotItem(pID); + bool IgnoreGrid; + if(Input()->KeyPressed(KEY_LALT) || Input()->KeyPressed(KEY_RALT)) + IgnoreGrid = true; + else + IgnoreGrid = false; + // draw selection background if(m_SelectedQuad == Index) { @@ -1066,7 +1072,7 @@ void CEditor::DoQuad(CQuad *q, int Index) // check if we only should move pivot if(s_Operation == OP_MOVE_PIVOT) { - if(m_GridActive) + if(m_GridActive && !IgnoreGrid) { int LineDistance = GetLineDistance(); @@ -1093,7 +1099,7 @@ void CEditor::DoQuad(CQuad *q, int Index) else if(s_Operation == OP_MOVE_ALL) { // move all points including pivot - if(m_GridActive) + if(m_GridActive && !IgnoreGrid) { int LineDistance = GetLineDistance(); @@ -1172,7 +1178,7 @@ void CEditor::DoQuad(CQuad *q, int Index) ms_pUiGotContext = pID; Graphics()->SetColor(1,1,1,1); - m_pTooltip = "Left mouse button to move. Hold shift to move pivot. Hold ctrl to rotate."; + m_pTooltip = "Left mouse button to move. Hold shift to move pivot. Hold ctrl to rotate. Hold alt to ignore grid."; if(UI()->MouseButton(0)) { @@ -1249,6 +1255,12 @@ void CEditor::DoQuadPoint(CQuad *pQuad, int QuadIndex, int V) static bool s_Moved; static int s_Operation = OP_NONE; + bool IgnoreGrid; + if(Input()->KeyPressed(KEY_LALT) || Input()->KeyPressed(KEY_RALT)) + IgnoreGrid = true; + else + IgnoreGrid = false; + if(UI()->ActiveItem() == pID) { float dx = m_MouseDeltaWx; @@ -1263,7 +1275,7 @@ void CEditor::DoQuadPoint(CQuad *pQuad, int QuadIndex, int V) { if(s_Operation == OP_MOVEPOINT) { - if(m_GridActive) + if(m_GridActive && !IgnoreGrid) { for(int m = 0; m < 4; m++) if(m_SelectedPoints&(1<SetColor(1,1,1,1); - m_pTooltip = "Left mouse button to move. Hold shift to move the texture."; + m_pTooltip = "Left mouse button to move. Hold shift to move the texture. Hold alt to ignore grid."; if(UI()->MouseButton(0)) { @@ -1514,11 +1526,17 @@ void CEditor::DoQuadEnvPoint(CQuad *pQuad, int QIndex, int PIndex) s_ActQIndex = QIndex; } + bool IgnoreGrid; + if(Input()->KeyPressed(KEY_LALT) || Input()->KeyPressed(KEY_RALT)) + IgnoreGrid = true; + else + IgnoreGrid = false; + if(UI()->ActiveItem() == pID && s_ActQIndex == QIndex) { if(s_Operation == OP_MOVE) { - if(m_GridActive) + if(m_GridActive && !IgnoreGrid) { int LineDistance = GetLineDistance(); @@ -1562,7 +1580,7 @@ void CEditor::DoQuadEnvPoint(CQuad *pQuad, int QIndex, int PIndex) ms_pUiGotContext = pID; Graphics()->SetColor(1.0f, 1.0f, 1.0f, 1.0f); - m_pTooltip = "Left mouse button to move. Hold ctrl to rotate."; + m_pTooltip = "Left mouse button to move. Hold ctrl to rotate. Hold alt to ignore grid."; if(UI()->MouseButton(0)) { -- cgit 1.4.1 From 58f57795081e677e1450844bad1043b72c7c0bea Mon Sep 17 00:00:00 2001 From: oy Date: Sun, 8 Jan 2012 01:14:52 +0100 Subject: - disabled clipping lines in the tile picker - fixed aspect ratio of the image in the tile picker Closes #833 --- src/game/editor/editor.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/game/editor/editor.cpp') diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index 17b45bf2..c19fc86f 100644 --- a/src/game/editor/editor.cpp +++ b/src/game/editor/editor.cpp @@ -1641,6 +1641,12 @@ void CEditor::DoMapEditor(CUIRect View, CUIRect ToolBar) pT->ShowInfo(); } } + else + { + // fix aspect ratio of the image in the picker + float Max = min(View.w, View.h); + View.w = View.h = Max; + } static void *s_pEditorID = (void *)&s_pEditorID; int Inside = UI()->MouseInside(&View); @@ -1965,7 +1971,7 @@ void CEditor::DoMapEditor(CUIRect View, CUIRect ToolBar) } } - if(GetSelectedGroup() && GetSelectedGroup()->m_UseClipping) + if(!m_ShowPicker && GetSelectedGroup() && GetSelectedGroup()->m_UseClipping) { CLayerGroup *g = m_Map.m_pGameGroup; g->MapScreen(); -- cgit 1.4.1 From be37147342ff9032f0557d732abfc6cfd2c77efe Mon Sep 17 00:00:00 2001 From: oy Date: Sun, 8 Jan 2012 01:47:53 +0100 Subject: fixed border rendering in the editor's image preview. Closes #908 --- src/engine/client/backend_sdl.cpp | 14 ++++++++++++++ src/engine/client/graphics.cpp | 12 ++++++++++++ src/engine/client/graphics.h | 3 +++ src/engine/client/graphics_threaded.cpp | 11 +++++++++++ src/engine/client/graphics_threaded.h | 10 ++++++++++ src/engine/graphics.h | 2 ++ src/game/editor/editor.cpp | 3 ++- src/game/editor/popups.cpp | 13 +++++++------ 8 files changed, 61 insertions(+), 7 deletions(-) (limited to 'src/game/editor/editor.cpp') diff --git a/src/engine/client/backend_sdl.cpp b/src/engine/client/backend_sdl.cpp index 3f74f87e..4f738949 100644 --- a/src/engine/client/backend_sdl.cpp +++ b/src/engine/client/backend_sdl.cpp @@ -133,6 +133,20 @@ void CCommandProcessorFragment_OpenGL::SetState(const CCommandBuffer::SState &St else glDisable(GL_TEXTURE_2D); + switch(State.m_WrapMode) + { + case CCommandBuffer::WRAP_REPEAT: + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); + break; + case CCommandBuffer::WRAP_CLAMP: + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + break; + default: + dbg_msg("render", "unknown wrapmode %d\n", State.m_WrapMode); + }; + // screen mapping glMatrixMode(GL_PROJECTION); glLoadIdentity(); diff --git a/src/engine/client/graphics.cpp b/src/engine/client/graphics.cpp index ad3926f2..5baff939 100644 --- a/src/engine/client/graphics.cpp +++ b/src/engine/client/graphics.cpp @@ -197,6 +197,18 @@ void CGraphics_OpenGL::BlendAdditive() glBlendFunc(GL_SRC_ALPHA, GL_ONE); } +void CGraphics_OpenGL::WrapNormal() +{ + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); +} + +void CGraphics_OpenGL::WrapClamp() +{ + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); +} + int CGraphics_OpenGL::MemoryUsage() const { return m_TextureMemoryUsage; diff --git a/src/engine/client/graphics.h b/src/engine/client/graphics.h index 3ab550dc..fdd83aa7 100644 --- a/src/engine/client/graphics.h +++ b/src/engine/client/graphics.h @@ -78,6 +78,9 @@ public: virtual void BlendNormal(); virtual void BlendAdditive(); + virtual void WrapNormal(); + virtual void WrapClamp(); + virtual int MemoryUsage() const; virtual void MapScreen(float TopLeftX, float TopLeftY, float BottomRightX, float BottomRightY); diff --git a/src/engine/client/graphics_threaded.cpp b/src/engine/client/graphics_threaded.cpp index c6947e33..286428d7 100644 --- a/src/engine/client/graphics_threaded.cpp +++ b/src/engine/client/graphics_threaded.cpp @@ -154,6 +154,7 @@ CGraphics_Threaded::CGraphics_Threaded() m_State.m_ClipH = 0; m_State.m_Texture = -1; m_State.m_BlendMode = CCommandBuffer::BLEND_NONE; + m_State.m_WrapMode = CCommandBuffer::WRAP_REPEAT; m_CurrentCommandBuffer = 0; m_pCommandBuffer = 0x0; @@ -214,6 +215,16 @@ void CGraphics_Threaded::BlendAdditive() m_State.m_BlendMode = CCommandBuffer::BLEND_ADDITIVE; } +void CGraphics_Threaded::WrapNormal() +{ + m_State.m_WrapMode = CCommandBuffer::WRAP_REPEAT; +} + +void CGraphics_Threaded::WrapClamp() +{ + m_State.m_WrapMode = CCommandBuffer::WRAP_CLAMP; +} + int CGraphics_Threaded::MemoryUsage() const { return m_TextureMemoryUsage; diff --git a/src/engine/client/graphics_threaded.h b/src/engine/client/graphics_threaded.h index f4f17ec2..3f3bec89 100644 --- a/src/engine/client/graphics_threaded.h +++ b/src/engine/client/graphics_threaded.h @@ -120,6 +120,12 @@ public: BLEND_ADDITIVE, }; + enum + { + WRAP_REPEAT = 0, + WRAP_CLAMP, + }; + struct SPoint { float x, y, z; }; struct STexCoord { float u, v; }; struct SColor { float r, g, b, a; }; @@ -142,6 +148,7 @@ public: struct SState { int m_BlendMode; + int m_WrapMode; int m_Texture; SPoint m_ScreenTL; SPoint m_ScreenBR; @@ -382,6 +389,9 @@ public: virtual void BlendNormal(); virtual void BlendAdditive(); + virtual void WrapNormal(); + virtual void WrapClamp(); + virtual int MemoryUsage() const; virtual void MapScreen(float TopLeftX, float TopLeftY, float BottomRightX, float BottomRightY); diff --git a/src/engine/graphics.h b/src/engine/graphics.h index 6d31060e..46750e03 100644 --- a/src/engine/graphics.h +++ b/src/engine/graphics.h @@ -77,6 +77,8 @@ public: virtual void BlendNone() = 0; virtual void BlendNormal() = 0; virtual void BlendAdditive() = 0; + virtual void WrapNormal() = 0; + virtual void WrapClamp() = 0; virtual int MemoryUsage() const = 0; virtual int LoadPNG(CImageInfo *pImg, const char *pFilename, int StorageType) = 0; diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index c19fc86f..6b0a401c 100644 --- a/src/game/editor/editor.cpp +++ b/src/game/editor/editor.cpp @@ -2679,11 +2679,12 @@ void CEditor::RenderImages(CUIRect ToolBox, CUIRect ToolBar, CUIRect View) r.h *= m_Map.m_lImages[i]->m_Height/Max; Graphics()->TextureSet(m_Map.m_lImages[i]->m_TexID); Graphics()->BlendNormal(); + Graphics()->WrapClamp(); Graphics()->QuadsBegin(); IGraphics::CQuadItem QuadItem(r.x, r.y, r.w, r.h); Graphics()->QuadsDrawTL(&QuadItem, 1); Graphics()->QuadsEnd(); - + Graphics()->WrapNormal(); } } diff --git a/src/game/editor/popups.cpp b/src/game/editor/popups.cpp index c19adb82..64d0c799 100644 --- a/src/game/editor/popups.cpp +++ b/src/game/editor/popups.cpp @@ -742,13 +742,14 @@ int CEditor::PopupSelectImage(CEditor *pEditor, CUIRect View) ImageView.w *= pEditor->m_Map.m_lImages[ShowImage]->m_Width/Max; ImageView.h *= pEditor->m_Map.m_lImages[ShowImage]->m_Height/Max; pEditor->Graphics()->TextureSet(pEditor->m_Map.m_lImages[ShowImage]->m_TexID); + pEditor->Graphics()->BlendNormal(); + pEditor->Graphics()->WrapClamp(); + pEditor->Graphics()->QuadsBegin(); + IGraphics::CQuadItem QuadItem(ImageView.x, ImageView.y, ImageView.w, ImageView.h); + pEditor->Graphics()->QuadsDrawTL(&QuadItem, 1); + pEditor->Graphics()->QuadsEnd(); + pEditor->Graphics()->WrapNormal(); } - else - pEditor->Graphics()->TextureSet(-1); - pEditor->Graphics()->QuadsBegin(); - IGraphics::CQuadItem QuadItem(ImageView.x, ImageView.y, ImageView.w, ImageView.h); - pEditor->Graphics()->QuadsDrawTL(&QuadItem, 1); - pEditor->Graphics()->QuadsEnd(); return 0; } -- cgit 1.4.1 From bafd22ebe7e249e05ba4b64266196935abcc5c66 Mon Sep 17 00:00:00 2001 From: oy Date: Sun, 8 Jan 2012 13:14:02 +0100 Subject: show path in the editor file dialog. Closes #786 --- src/engine/shared/storage.cpp | 12 ++++++++++++ src/engine/storage.h | 1 + src/game/editor/editor.cpp | 13 ++++++++++++- 3 files changed, 25 insertions(+), 1 deletion(-) (limited to 'src/game/editor/editor.cpp') diff --git a/src/engine/shared/storage.cpp b/src/engine/shared/storage.cpp index d6f83dc8..c1888188 100644 --- a/src/engine/shared/storage.cpp +++ b/src/engine/shared/storage.cpp @@ -377,6 +377,18 @@ public: return !fs_makedir(GetPath(Type, pFoldername, aBuffer, sizeof(aBuffer))); } + virtual void GetCompletePath(int Type, const char *pDir, char *pBuffer, unsigned BufferSize) + { + if(Type < 0 || Type >= m_NumPaths) + { + if(BufferSize > 0) + pBuffer[0] = 0; + return; + } + + GetPath(Type, pDir, pBuffer, BufferSize); + } + static IStorage *Create(const char *pApplicationName, int NumArgs, const char **ppArguments) { CStorage *p = new CStorage(); diff --git a/src/engine/storage.h b/src/engine/storage.h index 1fd48f6a..bcfb9ce2 100644 --- a/src/engine/storage.h +++ b/src/engine/storage.h @@ -21,6 +21,7 @@ public: virtual bool RemoveFile(const char *pFilename, int Type) = 0; virtual bool RenameFile(const char* pOldFilename, const char* pNewFilename, int Type) = 0; virtual bool CreateFolder(const char *pFoldername, int Type) = 0; + virtual void GetCompletePath(int Type, const char *pDir, char *pBuffer, unsigned BufferSize) = 0; }; extern IStorage *CreateStorage(const char *pApplicationName, int NumArgs, const char **ppArguments); diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index 6b0a401c..a5a9392a 100644 --- a/src/game/editor/editor.cpp +++ b/src/game/editor/editor.cpp @@ -2781,11 +2781,13 @@ void CEditor::RenderFileDialog() RenderTools()->DrawUIRect(&View, vec4(0,0,0,0.75f), CUI::CORNER_ALL, 5.0f); View.Margin(10.0f, &View); - CUIRect Title, FileBox, FileBoxLabel, ButtonBar, Scroll; + CUIRect Title, FileBox, FileBoxLabel, ButtonBar, Scroll, PathBox; View.HSplitTop(18.0f, &Title, &View); View.HSplitTop(5.0f, 0, &View); // some spacing View.HSplitBottom(14.0f, &View, &ButtonBar); View.HSplitBottom(10.0f, &View, 0); // some spacing + View.HSplitBottom(14.0f, &View, &PathBox); + View.HSplitBottom(5.0f, &View, 0); // some spacing View.HSplitBottom(14.0f, &View, &FileBox); FileBox.VSplitLeft(55.0f, &FileBoxLabel, &FileBox); View.HSplitBottom(10.0f, &View, 0); // some spacing @@ -2796,6 +2798,15 @@ void CEditor::RenderFileDialog() Title.VMargin(10.0f, &Title); UI()->DoLabel(&Title, m_pFileDialogTitle, 12.0f, -1, -1); + // pathbox + char aPath[128], aBuf[128]; + if(m_FilesSelectedIndex != -1) + Storage()->GetCompletePath(m_FileList[m_FilesSelectedIndex].m_StorageType, m_pFileDialogPath, aPath, sizeof(aPath)); + else + aPath[0] = 0; + str_format(aBuf, sizeof(aBuf), "Current path: %s", aPath); + UI()->DoLabel(&PathBox, aBuf, 10.0f, -1, -1); + // filebox if(m_FileDialogStorageType == IStorage::TYPE_SAVE) { -- cgit 1.4.1 From f8b895181a19a53a47c04fd6ed273c36a4c02c21 Mon Sep 17 00:00:00 2001 From: oy Date: Sun, 8 Jan 2012 13:16:19 +0100 Subject: show animation/grid/zoom level in the map editor. Closes #780 --- src/game/editor/editor.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/game/editor/editor.cpp') diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index a5a9392a..4f93f4fa 100644 --- a/src/game/editor/editor.cpp +++ b/src/game/editor/editor.cpp @@ -3596,10 +3596,15 @@ void CEditor::RenderMenubar(CUIRect MenuBar) (void)0; */ + CUIRect Info; MenuBar.VSplitLeft(40.0f, 0, &MenuBar); + MenuBar.VSplitLeft(MenuBar.w*0.75f, &MenuBar, &Info); char aBuf[128]; str_format(aBuf, sizeof(aBuf), "File: %s", m_aFileName); UI()->DoLabel(&MenuBar, aBuf, 10.0f, -1, -1); + + str_format(aBuf, sizeof(aBuf), "Z: %i, A: %.1f, G: %i", m_ZoomLevel, m_AnimateSpeed, m_GridFactor); + UI()->DoLabel(&Info, aBuf, 10.0f, 1, -1); } void CEditor::Render() -- cgit 1.4.1 From a9db705c1497044b32d5a722d484b275af92246a Mon Sep 17 00:00:00 2001 From: oy Date: Sun, 8 Jan 2012 13:36:47 +0100 Subject: fixed that refocus is done when using Home-key in a editor edit box. Closes #821 --- src/game/editor/editor.cpp | 6 +++++- src/game/editor/editor.h | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'src/game/editor/editor.cpp') diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index 4f93f4fa..792c735a 100644 --- a/src/game/editor/editor.cpp +++ b/src/game/editor/editor.cpp @@ -228,6 +228,7 @@ int CEditor::DoEditBox(void *pID, const CUIRect *pRect, char *pStr, unsigned Str if(UI()->LastActiveItem() == pID) { + m_EditBoxActive = 2; int Len = str_length(pStr); if(Len == 0) s_AtIndex = 0; @@ -971,7 +972,7 @@ void CEditor::DoToolbar(CUIRect ToolBar) // refocus button TB_Bottom.VSplitLeft(50.0f, &Button, &TB_Bottom); static int s_RefocusButton = 0; - if(DoButton_Editor(&s_RefocusButton, "Refocus", m_WorldOffsetX&&m_WorldOffsetY?0:-1, &Button, 0, "[HOME] Restore map focus") || Input()->KeyDown(KEY_HOME)) + if(DoButton_Editor(&s_RefocusButton, "Refocus", m_WorldOffsetX&&m_WorldOffsetY?0:-1, &Button, 0, "[HOME] Restore map focus") || (m_EditBoxActive == 0 && Input()->KeyDown(KEY_HOME))) { m_WorldOffsetX = 0; m_WorldOffsetY = 0; @@ -3620,6 +3621,9 @@ void CEditor::Render() // reset tip m_pTooltip = 0; + if(m_EditBoxActive) + --m_EditBoxActive; + // render checker RenderBackground(View, ms_CheckerTexture, 32.0f, 1.0f); diff --git a/src/game/editor/editor.h b/src/game/editor/editor.h index f5d43dae..99ec964c 100644 --- a/src/game/editor/editor.h +++ b/src/game/editor/editor.h @@ -478,6 +478,7 @@ public: m_Mode = MODE_LAYERS; m_Dialog = 0; + m_EditBoxActive = 0; m_pTooltip = 0; m_GridActive = false; @@ -567,6 +568,7 @@ public: int m_Mode; int m_Dialog; + int m_EditBoxActive; const char *m_pTooltip; bool m_GridActive; -- cgit 1.4.1 From 65f4416164eb592efdcb56140f095944b485f8b6 Mon Sep 17 00:00:00 2001 From: SushiTee Date: Tue, 12 Jul 2011 23:31:39 +0200 Subject: added map info --- src/game/editor/editor.cpp | 20 +++++++++++++- src/game/editor/editor.h | 29 ++++++++++++++++++++ src/game/editor/io.cpp | 41 ++++++++++++++++++++++++++++ src/game/editor/popups.cpp | 68 ++++++++++++++++++++++++++++++++++++++++++++++ src/game/mapitems.h | 9 ++++++ 5 files changed, 166 insertions(+), 1 deletion(-) (limited to 'src/game/editor/editor.cpp') diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index 792c735a..fa1024e0 100644 --- a/src/game/editor/editor.cpp +++ b/src/game/editor/editor.cpp @@ -214,7 +214,6 @@ void CEditor::EnvelopeEval(float TimeOffset, int Env, float *pChannels, void *pU // copied from gc_menu.cpp, should be more generalized //extern int ui_do_edit_box(void *id, const CUIRect *rect, char *str, int str_size, float font_size, bool hidden=false); - int CEditor::DoEditBox(void *pID, const CUIRect *pRect, char *pStr, unsigned StrSize, float FontSize, float *Offset, bool Hidden, int Corners) { int Inside = UI()->MouseInside(pRect); @@ -2904,6 +2903,7 @@ void CEditor::RenderFileDialog() static int s_OkButton = 0; static int s_CancelButton = 0; static int s_NewFolderButton = 0; + static int s_MapInfoButton = 0; CUIRect Button; ButtonBar.VSplitRight(50.0f, &ButtonBar, &Button); @@ -2979,6 +2979,22 @@ void CEditor::RenderFileDialog() UI()->SetActiveItem(0); } } + + if(m_FileDialogStorageType == IStorage::TYPE_SAVE) + { + ButtonBar.VSplitLeft(40.0f, 0, &ButtonBar); + ButtonBar.VSplitLeft(70.0f, &Button, &ButtonBar); + if(DoButton_Editor(&s_MapInfoButton, "Map details", 0, &Button, 0, 0)) + { + str_copy(m_Map.m_MapInfo.m_aAuthorTmp, m_Map.m_MapInfo.m_aAuthor, sizeof(m_Map.m_MapInfo.m_aAuthorTmp)); + str_copy(m_Map.m_MapInfo.m_aVersionTmp, m_Map.m_MapInfo.m_aVersion, sizeof(m_Map.m_MapInfo.m_aVersionTmp)); + str_copy(m_Map.m_MapInfo.m_aCreditsTmp, m_Map.m_MapInfo.m_aCredits, sizeof(m_Map.m_MapInfo.m_aCreditsTmp)); + str_copy(m_Map.m_MapInfo.m_aLicenseTmp, m_Map.m_MapInfo.m_aLicense, sizeof(m_Map.m_MapInfo.m_aLicenseTmp)); + static int s_MapInfoPopupID = 0; + UiInvokePopupMenu(&s_MapInfoPopupID, 0, Width/2.0f-200.0f, Height/2.0f-100.0f, 400.0f, 200.0f, PopupMapInfo); + UI()->SetActiveItem(0); + } + } } void CEditor::FilelistPopulate(int StorageType) @@ -3889,6 +3905,8 @@ void CEditorMap::Clean() m_lEnvelopes.delete_all(); m_lImages.delete_all(); + m_MapInfo.Reset(); + m_pGameLayer = 0x0; m_pGameGroup = 0x0; diff --git a/src/game/editor/editor.h b/src/game/editor/editor.h index 99ec964c..a81474d9 100644 --- a/src/game/editor/editor.h +++ b/src/game/editor/editor.h @@ -276,6 +276,34 @@ public: array m_lImages; array m_lEnvelopes; + class CMapInfo + { + public: + char m_aAuthorTmp[32]; + char m_aVersionTmp[16]; + char m_aCreditsTmp[128]; + char m_aLicenseTmp[32]; + + char m_aAuthor[32]; + char m_aVersion[16]; + char m_aCredits[128]; + char m_aLicense[32]; + + void Reset() + { + m_aAuthorTmp[0] = 0; + m_aVersionTmp[0] = 0; + m_aCreditsTmp[0] = 0; + m_aLicenseTmp[0] = 0; + + m_aAuthor[0] = 0; + m_aVersion[0] = 0; + m_aCredits[0] = 0; + m_aLicense[0] = 0; + } + }; + CMapInfo m_MapInfo; + class CLayerGame *m_pGameLayer; CLayerGroup *m_pGameGroup; @@ -710,6 +738,7 @@ public: static int PopupQuad(CEditor *pEditor, CUIRect View); static int PopupPoint(CEditor *pEditor, CUIRect View); static int PopupNewFolder(CEditor *pEditor, CUIRect View); + static int PopupMapInfo(CEditor *pEditor, CUIRect View); static int PopupEvent(CEditor *pEditor, CUIRect View); static int PopupSelectImage(CEditor *pEditor, CUIRect View); static int PopupSelectGametileOp(CEditor *pEditor, CUIRect View); diff --git a/src/game/editor/io.cpp b/src/game/editor/io.cpp index aec7231b..463147e1 100644 --- a/src/game/editor/io.cpp +++ b/src/game/editor/io.cpp @@ -220,6 +220,31 @@ int CEditorMap::Save(class IStorage *pStorage, const char *pFileName) df.AddItem(MAPITEMTYPE_VERSION, 0, sizeof(Item), &Item); } + // save map info + { + CMapItemInfo Item; + Item.m_Version = 1; + + if(m_MapInfo.m_aAuthor[0]) + Item.m_Author = df.AddData(str_length(m_MapInfo.m_aAuthor)+1, m_MapInfo.m_aAuthor); + else + Item.m_Author = -1; + if(m_MapInfo.m_aVersion[0]) + Item.m_MapVersion = df.AddData(str_length(m_MapInfo.m_aVersion)+1, m_MapInfo.m_aVersion); + else + Item.m_MapVersion = -1; + if(m_MapInfo.m_aCredits[0]) + Item.m_Credits = df.AddData(str_length(m_MapInfo.m_aCredits)+1, m_MapInfo.m_aCredits); + else + Item.m_Credits = -1; + if(m_MapInfo.m_aLicense[0]) + Item.m_License = df.AddData(str_length(m_MapInfo.m_aLicense)+1, m_MapInfo.m_aLicense); + else + Item.m_License = -1; + + df.AddItem(MAPITEMTYPE_INFO, 0, sizeof(Item), &Item); + } + // save images for(int i = 0; i < m_lImages.size(); i++) { @@ -414,6 +439,22 @@ int CEditorMap::Load(class IStorage *pStorage, const char *pFileName, int Storag { //editor.reset(false); + // load map info + { + CMapItemInfo *pItem = (CMapItemInfo *)DataFile.FindItem(MAPITEMTYPE_INFO, 0); + if(pItem && pItem->m_Version == 1) + { + if(pItem->m_Author > -1) + str_copy(m_MapInfo.m_aAuthor, (char *)DataFile.GetData(pItem->m_Author), sizeof(m_MapInfo.m_aAuthor)); + if(pItem->m_MapVersion > -1) + str_copy(m_MapInfo.m_aVersion, (char *)DataFile.GetData(pItem->m_MapVersion), sizeof(m_MapInfo.m_aVersion)); + if(pItem->m_Credits > -1) + str_copy(m_MapInfo.m_aCredits, (char *)DataFile.GetData(pItem->m_Credits), sizeof(m_MapInfo.m_aCredits)); + if(pItem->m_License > -1) + str_copy(m_MapInfo.m_aLicense, (char *)DataFile.GetData(pItem->m_License), sizeof(m_MapInfo.m_aLicense)); + } + } + // load images { int Start, Num; diff --git a/src/game/editor/popups.cpp b/src/game/editor/popups.cpp index 64d0c799..2382823d 100644 --- a/src/game/editor/popups.cpp +++ b/src/game/editor/popups.cpp @@ -635,6 +635,74 @@ int CEditor::PopupNewFolder(CEditor *pEditor, CUIRect View) return 0; } +int CEditor::PopupMapInfo(CEditor *pEditor, CUIRect View) +{ + CUIRect Label, ButtonBar, Button; + + // title + View.HSplitTop(10.0f, 0, &View); + View.HSplitTop(30.0f, &Label, &View); + pEditor->UI()->DoLabel(&Label, "Map details", 20.0f, 0); + + View.HSplitBottom(10.0f, &View, 0); + View.HSplitBottom(20.0f, &View, &ButtonBar); + + View.VMargin(40.0f, &View); + + // author box + View.HSplitTop(20.0f, &Label, &View); + pEditor->UI()->DoLabel(&Label, "Author:", 10.0f, -1); + Label.VSplitLeft(40.0f, 0, &Button); + Button.HSplitTop(12.0f, &Button, 0); + static float s_AuthorBox = 0; + pEditor->DoEditBox(&s_AuthorBox, &Button, pEditor->m_Map.m_MapInfo.m_aAuthorTmp, sizeof(pEditor->m_Map.m_MapInfo.m_aAuthorTmp), 10.0f, &s_AuthorBox); + + // version box + View.HSplitTop(20.0f, &Label, &View); + pEditor->UI()->DoLabel(&Label, "Version:", 10.0f, -1); + Label.VSplitLeft(40.0f, 0, &Button); + Button.HSplitTop(12.0f, &Button, 0); + static float s_VersionBox = 0; + pEditor->DoEditBox(&s_VersionBox, &Button, pEditor->m_Map.m_MapInfo.m_aVersionTmp, sizeof(pEditor->m_Map.m_MapInfo.m_aVersionTmp), 10.0f, &s_VersionBox); + + // credits box + View.HSplitTop(20.0f, &Label, &View); + pEditor->UI()->DoLabel(&Label, "Credits:", 10.0f, -1); + Label.VSplitLeft(40.0f, 0, &Button); + Button.HSplitTop(12.0f, &Button, 0); + static float s_CreditsBox = 0; + pEditor->DoEditBox(&s_CreditsBox, &Button, pEditor->m_Map.m_MapInfo.m_aCreditsTmp, sizeof(pEditor->m_Map.m_MapInfo.m_aCreditsTmp), 10.0f, &s_CreditsBox); + + // license box + View.HSplitTop(20.0f, &Label, &View); + pEditor->UI()->DoLabel(&Label, "License:", 10.0f, -1); + Label.VSplitLeft(40.0f, 0, &Button); + Button.HSplitTop(12.0f, &Button, 0); + static float s_LicenseBox = 0; + pEditor->DoEditBox(&s_LicenseBox, &Button, pEditor->m_Map.m_MapInfo.m_aLicenseTmp, sizeof(pEditor->m_Map.m_MapInfo.m_aLicenseTmp), 10.0f, &s_LicenseBox); + + // button bar + ButtonBar.VSplitLeft(30.0f, 0, &ButtonBar); + ButtonBar.VSplitLeft(110.0f, &Label, &ButtonBar); + static int s_CreateButton = 0; + if(pEditor->DoButton_Editor(&s_CreateButton, "Save", 0, &Label, 0, 0)) + { + str_copy(pEditor->m_Map.m_MapInfo.m_aAuthor, pEditor->m_Map.m_MapInfo.m_aAuthorTmp, sizeof(pEditor->m_Map.m_MapInfo.m_aAuthor)); + str_copy(pEditor->m_Map.m_MapInfo.m_aVersion, pEditor->m_Map.m_MapInfo.m_aVersionTmp, sizeof(pEditor->m_Map.m_MapInfo.m_aVersion)); + str_copy(pEditor->m_Map.m_MapInfo.m_aCredits, pEditor->m_Map.m_MapInfo.m_aCreditsTmp, sizeof(pEditor->m_Map.m_MapInfo.m_aCredits)); + str_copy(pEditor->m_Map.m_MapInfo.m_aLicense, pEditor->m_Map.m_MapInfo.m_aLicenseTmp, sizeof(pEditor->m_Map.m_MapInfo.m_aLicense)); + return 1; + } + + ButtonBar.VSplitRight(30.0f, &ButtonBar, 0); + ButtonBar.VSplitRight(110.0f, &ButtonBar, &Label); + static int s_AbortButton = 0; + if(pEditor->DoButton_Editor(&s_AbortButton, "Abort", 0, &Label, 0, 0)) + return 1; + + return 0; +} + int CEditor::PopupEvent(CEditor *pEditor, CUIRect View) { CUIRect Label, ButtonBar; diff --git a/src/game/mapitems.h b/src/game/mapitems.h index bb2f4d19..e1dda4ee 100644 --- a/src/game/mapitems.h +++ b/src/game/mapitems.h @@ -90,6 +90,15 @@ public: unsigned char m_Reserved; }; +struct CMapItemInfo +{ + int m_Version; + int m_Author; + int m_MapVersion; + int m_Credits; + int m_License; +} ; + struct CMapItemImage { int m_Version; -- cgit 1.4.1