mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Total Cleanup
Signed-off-by: GreYFoXGTi <GreYFoXGTi@GMaiL.CoM>
This commit is contained in:
parent
9fde901705
commit
896634a061
|
@ -1,4 +1,4 @@
|
|||
|
||||
|
||||
##### translated strings #####
|
||||
|
||||
%d of %d servers, %d players
|
||||
|
|
|
@ -225,8 +225,6 @@ image_particles = Image("particles", "particles.png")
|
|||
image_game = Image("game", "game.png")
|
||||
image_browseicons = Image("browseicons", "browse_icons.png")
|
||||
image_emoticons = Image("emoticons", "emoticons.png")
|
||||
image_arrows = Image("arrows", "arrows.png")
|
||||
image_speedup_arrow = Image("speedup_arrow", "editor/speed_arrow.png")
|
||||
image_demobuttons = Image("demobuttons", "demo_buttons.png")
|
||||
|
||||
container.images.Add(image_null)
|
||||
|
@ -236,10 +234,8 @@ container.images.Add(Image("cursor", "gui_cursor.png"))
|
|||
container.images.Add(Image("banner", "gui_logo.png"))
|
||||
container.images.Add(image_emoticons)
|
||||
container.images.Add(image_browseicons)
|
||||
container.images.Add(image_arrows)
|
||||
container.images.Add(Image("console_bg", "console.png"))
|
||||
container.images.Add(Image("console_bar", "console_bar.png"))
|
||||
container.images.Add(image_speedup_arrow)
|
||||
container.images.Add(image_demobuttons)
|
||||
|
||||
container.pickups.Add(Pickup("health"))
|
||||
|
@ -252,8 +248,6 @@ set_game = SpriteSet("game", image_game, 32, 16)
|
|||
set_tee = SpriteSet("tee", image_null, 8, 4)
|
||||
set_browseicons = SpriteSet("browseicons", image_browseicons, 4, 1)
|
||||
set_emoticons = SpriteSet("emoticons", image_emoticons, 4, 4)
|
||||
set_arrows = SpriteSet("arrows", image_arrows, 2, 12)
|
||||
set_speedup_arrow = SpriteSet("speedup_arrow", image_speedup_arrow, 1, 1)
|
||||
set_demobuttons = SpriteSet("demobuttons", image_demobuttons, 5, 1)
|
||||
|
||||
container.spritesets.Add(set_particles)
|
||||
|
@ -261,8 +255,6 @@ container.spritesets.Add(set_game)
|
|||
container.spritesets.Add(set_tee)
|
||||
container.spritesets.Add(set_browseicons)
|
||||
container.spritesets.Add(set_emoticons)
|
||||
container.spritesets.Add(set_arrows)
|
||||
container.spritesets.Add(set_speedup_arrow)
|
||||
container.spritesets.Add(set_demobuttons)
|
||||
|
||||
container.sprites.Add(Sprite("part_slice", set_particles, 0,0,1,1))
|
||||
|
@ -281,13 +273,6 @@ container.sprites.Add(Sprite("health_empty", set_game, 23,0,2,2))
|
|||
container.sprites.Add(Sprite("armor_full", set_game, 21,2,2,2))
|
||||
container.sprites.Add(Sprite("armor_empty", set_game, 23,2,2,2))
|
||||
|
||||
container.sprites.Add(Sprite("arrow_left", set_arrows, 0,0,2,2))
|
||||
container.sprites.Add(Sprite("arrow_right", set_arrows, 0,2,2,2))
|
||||
container.sprites.Add(Sprite("arrow_join", set_arrows, 0,4,2,2))
|
||||
container.sprites.Add(Sprite("arrow_spec", set_arrows, 0,6,2,2))
|
||||
container.sprites.Add(Sprite("arrow_red", set_arrows, 0,8,2,2))
|
||||
container.sprites.Add(Sprite("arrow_green", set_arrows, 0,10,2,2))
|
||||
|
||||
container.sprites.Add(Sprite("star1", set_game, 15,0,2,2))
|
||||
container.sprites.Add(Sprite("star2", set_game, 17,0,2,2))
|
||||
container.sprites.Add(Sprite("star3", set_game, 19,0,2,2))
|
||||
|
@ -381,14 +366,13 @@ container.sprites.Add(Sprite("browse_lock", set_browseicons, 0,0,1,1))
|
|||
container.sprites.Add(Sprite("browse_heart", set_browseicons, 1,0,1,1))
|
||||
container.sprites.Add(Sprite("browse_unpure", set_browseicons, 3,0,1,1))
|
||||
|
||||
container.sprites.Add(Sprite("speedup_arrow", set_speedup_arrow, 0,0,1,1))
|
||||
|
||||
container.sprites.Add(Sprite("demobutton_play", set_demobuttons, 0,0,1,1))
|
||||
container.sprites.Add(Sprite("demobutton_pause", set_demobuttons, 1,0,1,1))
|
||||
container.sprites.Add(Sprite("demobutton_stop", set_demobuttons, 2,0,1,1))
|
||||
container.sprites.Add(Sprite("demobutton_slower", set_demobuttons, 3,0,1,1))
|
||||
container.sprites.Add(Sprite("demobutton_faster", set_demobuttons, 4,0,1,1))
|
||||
|
||||
|
||||
anim = Animation("base")
|
||||
anim.body.frames.Add(AnimKeyframe(0, 0, -4, 0))
|
||||
anim.back_foot.frames.Add(AnimKeyframe(0, 0, 10, 0))
|
||||
|
|
|
@ -252,7 +252,7 @@ Messages = [
|
|||
NetIntRange("m_Pass", 0, 'MAX_CLIENTS'),
|
||||
NetIntRange("m_Total", 0, 'MAX_CLIENTS'),
|
||||
]),
|
||||
|
||||
|
||||
### Client messages
|
||||
NetMessage("Cl_Say", [
|
||||
NetBool("m_Team"),
|
||||
|
@ -293,29 +293,4 @@ Messages = [
|
|||
NetStringStrict("m_Type"),
|
||||
NetStringStrict("m_Value"),
|
||||
]),
|
||||
|
||||
NetMessage("Cl_IsRace", []),
|
||||
|
||||
NetMessage("Cl_RaceShowOthers", [
|
||||
NetBool("m_Active"),
|
||||
]),
|
||||
|
||||
NetMessage("Sv_RaceTime", [
|
||||
NetIntAny("m_Time"),
|
||||
NetIntAny("m_Check"),
|
||||
]),
|
||||
|
||||
NetMessage("Sv_Record", [
|
||||
NetIntAny("m_Time"),
|
||||
]),
|
||||
|
||||
NetMessage("Sv_PlayerTime", [
|
||||
NetIntAny("m_Time"),
|
||||
NetIntRange("m_Cid", 0, 'MAX_CLIENTS-1'),
|
||||
]),
|
||||
|
||||
NetMessage("Sv_PlayerTeam", [
|
||||
NetIntAny("m_Team"),
|
||||
NetIntRange("m_Cid", 0, 'MAX_CLIENTS-1'),
|
||||
]),
|
||||
]
|
||||
|
|
|
@ -82,7 +82,6 @@ public:
|
|||
//
|
||||
virtual int MapDownloadAmount() = 0;
|
||||
virtual int MapDownloadTotalsize() = 0;
|
||||
virtual const char* MapDownloadName() = 0;
|
||||
|
||||
// input
|
||||
virtual int *GetInput(int Tick) = 0;
|
||||
|
@ -129,11 +128,6 @@ public:
|
|||
virtual const char *ErrorString() = 0;
|
||||
virtual const char *LatestVersion() = 0;
|
||||
virtual bool ConnectionProblems() = 0;
|
||||
|
||||
// Race
|
||||
virtual const char* GetCurrentMap() = 0;
|
||||
virtual const char* RaceRecordStart(const char *pFilename) = 0;
|
||||
virtual void RaceRecordStop() = 0;
|
||||
};
|
||||
|
||||
class IGameClient : public IInterface
|
||||
|
|
|
@ -751,10 +751,8 @@ const char *CClient::ErrorString()
|
|||
|
||||
void CClient::Render()
|
||||
{
|
||||
//if(g_Config.m_GfxClear)
|
||||
// Graphics()->Clear(1,1,0);
|
||||
if(g_Config.m_GfxClear || g_Config.m_GfxClearFull)
|
||||
Graphics()->Clear(0.3f,0.3f,0.6f);
|
||||
if(g_Config.m_GfxClear)
|
||||
Graphics()->Clear(1,1,0);
|
||||
|
||||
GameClient()->OnRender();
|
||||
DebugRender();
|
||||
|
@ -1873,31 +1871,6 @@ void CClient::Con_AddFavorite(IConsole::IResult *pResult, void *pUserData, int C
|
|||
pSelf->m_ServerBrowser.AddFavorite(Addr);
|
||||
}
|
||||
|
||||
// DDRace
|
||||
const char* CClient::GetCurrentMap()
|
||||
{
|
||||
return m_aCurrentMap;
|
||||
}
|
||||
|
||||
const char* CClient::RaceRecordStart(const char *pFilename)
|
||||
{
|
||||
char aFilename[128];
|
||||
str_format(aFilename, sizeof(aFilename), "demos/%s_%s.demo", m_aCurrentMap, pFilename);
|
||||
|
||||
if(State() != STATE_ONLINE)
|
||||
dbg_msg("demorec/record", "client is not online");
|
||||
else
|
||||
m_DemoRecorder.Start(Storage(), m_pConsole, aFilename, GameClient()->NetVersion(), m_aCurrentMap, m_CurrentMapCrc, "client");
|
||||
|
||||
return m_aCurrentMap;
|
||||
}
|
||||
|
||||
void CClient::RaceRecordStop()
|
||||
{
|
||||
if(m_DemoRecorder.IsRecording())
|
||||
m_DemoRecorder.Stop();
|
||||
}
|
||||
|
||||
const char *CClient::DemoPlayer_Play(const char *pFilename)
|
||||
{
|
||||
int Crc;
|
||||
|
|
|
@ -251,7 +251,6 @@ public:
|
|||
|
||||
virtual int MapDownloadAmount() { return m_MapdownloadAmount; }
|
||||
virtual int MapDownloadTotalsize() { return m_MapdownloadTotalsize; }
|
||||
virtual const char* MapDownloadName() { return m_aMapdownloadName; }
|
||||
|
||||
void PumpNetwork();
|
||||
|
||||
|
@ -282,11 +281,6 @@ public:
|
|||
static void Con_Record(IConsole::IResult *pResult, void *pUserData, int ClientID);
|
||||
static void Con_StopRecord(IConsole::IResult *pResult, void *pUserData, int ClientID);
|
||||
|
||||
// DDRace
|
||||
virtual const char* GetCurrentMap();
|
||||
virtual const char* RaceRecordStart(const char *pFilename);
|
||||
virtual void RaceRecordStop();
|
||||
|
||||
void RegisterCommands();
|
||||
|
||||
const char *DemoPlayer_Play(const char *pFilename);
|
||||
|
|
|
@ -7,8 +7,8 @@ class CInput : public IEngineInput
|
|||
|
||||
int m_InputGrabbed;
|
||||
|
||||
unsigned int m_LastRelease;
|
||||
int m_ReleaseDelta;
|
||||
int64 m_LastRelease;
|
||||
int64 m_ReleaseDelta;
|
||||
|
||||
void AddEvent(int Unicode, int Key, int Flags);
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ public:
|
|||
//virtual const char *InterfaceName() { return name; }
|
||||
|
||||
|
||||
// This kernel thingie makes the structure very flat and basically singletons.
|
||||
// This kernel thingie makes the structure very flat and basiclly singletons.
|
||||
// I'm not sure if this is a good idea but it works for now.
|
||||
class IKernel
|
||||
{
|
||||
|
|
|
@ -217,12 +217,6 @@ public:
|
|||
return !Fail;
|
||||
}
|
||||
|
||||
virtual const char* SavePath(const char *pFilename, char *pBuffer, int Max)
|
||||
{
|
||||
str_format(pBuffer, Max, "%s/%s", m_aApplicationSavePath, pFilename);
|
||||
return pBuffer;
|
||||
}
|
||||
|
||||
static IStorage *Create(const char *pApplicationName, int NumArgs, const char **ppArguments)
|
||||
{
|
||||
CStorage *p = new CStorage();
|
||||
|
@ -233,11 +227,6 @@ public:
|
|||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
const char* ApplicationSavePath()
|
||||
{
|
||||
return m_aApplicationSavePath;
|
||||
}
|
||||
};
|
||||
|
||||
IStorage *CreateStorage(const char *pApplicationName, int NumArgs, const char **ppArguments) { return CStorage::Create(pApplicationName, NumArgs, ppArguments); }
|
||||
|
|
|
@ -19,8 +19,6 @@ public:
|
|||
virtual const char *GetDirectory(int Type) const = 0;
|
||||
virtual IOHANDLE OpenFile(const char *pFilename, int Flags, char *pBuffer = 0, int BufferSize = 0) = 0;
|
||||
virtual bool RemoveFile(const char *pFilename) = 0;
|
||||
virtual const char* ApplicationSavePath() = 0;
|
||||
virtual const char* SavePath(const char *pFilename, char *pBuffer, int Max) = 0;
|
||||
};
|
||||
|
||||
extern IStorage *CreateStorage(const char *pApplicationName, int NumArgs, const char **ppArguments);
|
||||
|
|
|
@ -8,52 +8,15 @@
|
|||
#include "camera.h"
|
||||
#include "controls.h"
|
||||
|
||||
const float ZoomStep = 0.75f;
|
||||
void CCamera::ConZoomPlus(IConsole::IResult *pResult, void *pUserData, int ClientID) {
|
||||
if(g_Config.m_ClRaceCheats == 1 || ((CCamera *)pUserData)->m_pClient->m_IsRace)
|
||||
((CCamera *)pUserData)->m_Zoom *= 1/ZoomStep;
|
||||
}
|
||||
void CCamera::ConZoomMinus(IConsole::IResult *pResult, void *pUserData, int ClientID) {
|
||||
if(g_Config.m_ClRaceCheats == 1 || ((CCamera *)pUserData)->m_pClient->m_IsRace)
|
||||
((CCamera *)pUserData)->m_Zoom *= ZoomStep;
|
||||
}
|
||||
void CCamera::ConZoomReset(IConsole::IResult *pResult, void *pUserData, int ClientID) {
|
||||
if(g_Config.m_ClRaceCheats == 1 || ((CCamera *)pUserData)->m_pClient->m_IsRace)
|
||||
((CCamera *)pUserData)->m_Zoom = 1.0f;
|
||||
}
|
||||
void CCamera::ConCameraFree(IConsole::IResult *pResult, void *pUserData, int ClientID) {
|
||||
if(!((CCamera *)pUserData)->m_pClient->m_Snap.m_Spectate && (g_Config.m_ClRaceCheats == 1 || ((CCamera *)pUserData)->m_pClient->m_IsRace))
|
||||
((CCamera *)pUserData)->m_Free = ((CCamera *)pUserData)->m_Free ? false : true;
|
||||
}
|
||||
|
||||
|
||||
CCamera::CCamera()
|
||||
{
|
||||
m_WasSpectator = false;
|
||||
m_Zoom = 1.0f;
|
||||
m_Free = false;
|
||||
m_Follow = -1;
|
||||
}
|
||||
|
||||
void CCamera::OnRender()
|
||||
{
|
||||
//vec2 center;
|
||||
|
||||
// update camera center
|
||||
if(m_pClient->m_Snap.m_Spectate || m_Free) {
|
||||
if(m_Follow == -1) {
|
||||
m_Center = m_pClient->m_pControls->m_MousePos;
|
||||
} else {
|
||||
CGameClient::CSnapState::CCharacterInfo* Char = getCharacter(m_Follow);
|
||||
if(Char == 0) {
|
||||
m_Follow = -1;
|
||||
m_Free = false;
|
||||
OnRender();
|
||||
} else {
|
||||
float l = length(m_pClient->m_pControls->m_MousePos);
|
||||
float DeadZone = g_Config.m_ClMouseDeadzone;
|
||||
float FollowFactor = g_Config.m_ClMouseFollowfactor/100.0f;
|
||||
vec2 CameraOffset(0, 0);
|
||||
m_Zoom = 1.0f;
|
||||
|
||||
// update camera center
|
||||
if(m_pClient->m_Snap.m_Spectate)
|
||||
|
@ -64,14 +27,6 @@ void CCamera::OnRender()
|
|||
m_WasSpectator = true;
|
||||
}
|
||||
m_Center = m_pClient->m_pControls->m_MousePos;
|
||||
float OffsetAmount = max(l-DeadZone, 0.0f) * FollowFactor;
|
||||
if(l > 0.0001f) // make sure that this isn't 0
|
||||
CameraOffset = normalize(m_pClient->m_pControls->m_MousePos)*OffsetAmount;
|
||||
vec2 Position = mix(vec2(Char->m_Prev.m_X, Char->m_Prev.m_Y), vec2(Char->m_Cur.m_X, Char->m_Cur.m_Y), Client()->IntraGameTick());
|
||||
m_Center = Position + CameraOffset;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -84,39 +39,11 @@ void CCamera::OnRender()
|
|||
float DeadZone = g_Config.m_ClMouseDeadzone;
|
||||
float FollowFactor = g_Config.m_ClMouseFollowfactor/100.0f;
|
||||
vec2 CameraOffset(0, 0);
|
||||
|
||||
float OffsetAmount = max(l-DeadZone, 0.0f) * FollowFactor;
|
||||
if(l > 0.0001f) // make sure that this isn't 0
|
||||
CameraOffset = normalize(m_pClient->m_pControls->m_MousePos)*OffsetAmount;
|
||||
|
||||
m_Center = m_pClient->m_LocalCharacterPos + CameraOffset;
|
||||
}
|
||||
}
|
||||
|
||||
void CCamera::OnConsoleInit()
|
||||
{
|
||||
Console()->Register("zoom+", "", CFGFLAG_CLIENT, ConZoomPlus, this, "Zoom increse", 0);
|
||||
Console()->Register("zoom-", "", CFGFLAG_CLIENT, ConZoomMinus, this, "Zoom decrese", 0);
|
||||
Console()->Register("zoom", "", CFGFLAG_CLIENT, ConZoomReset, this, "Zoom reset", 0);
|
||||
Console()->Register("camera_free", "", CFGFLAG_CLIENT, ConCameraFree, this, "Free camera On/Off", 0);
|
||||
}
|
||||
|
||||
CGameClient::CSnapState::CCharacterInfo* CCamera::getCharacter(int Id) {
|
||||
const CNetObj_PlayerInfo *pInfo = (const CNetObj_PlayerInfo *)Client()->SnapFindItem(IClient::SNAP_CURRENT, NETOBJTYPE_PLAYERINFO, Id);
|
||||
if(pInfo != 0 && pInfo->m_Team != -1) {
|
||||
return &m_pClient->m_Snap.m_aCharacters[Id];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool CCamera::SetFollow(int Id) {
|
||||
if(m_pClient->m_Snap.m_Spectate) {
|
||||
if(Id == -1) {
|
||||
m_Follow = -1;
|
||||
return false;
|
||||
}
|
||||
if(Id >= 0 || Id < MAX_CLIENTS) {
|
||||
m_Follow = Id;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
|
@ -2,29 +2,16 @@
|
|||
#define GAME_CLIENT_COMPONENTS_CAMERA_H
|
||||
#include <base/vmath.h>
|
||||
#include <game/client/component.h>
|
||||
#include <game/client/gameclient.h>
|
||||
|
||||
class CCamera : public CComponent
|
||||
{
|
||||
|
||||
static void ConZoomPlus(IConsole::IResult *pResult, void *pUserData, int ClientID);
|
||||
static void ConZoomMinus(IConsole::IResult *pResult, void *pUserData, int ClientID);
|
||||
static void ConZoomReset(IConsole::IResult *pResult, void *pUserData, int ClientID);
|
||||
static void ConCameraFree(IConsole::IResult *pResult, void *pUserData, int ClientID);
|
||||
|
||||
CGameClient::CSnapState::CCharacterInfo* getCharacter(int Id);
|
||||
|
||||
public:
|
||||
vec2 m_Center;
|
||||
float m_Zoom;
|
||||
bool m_WasSpectator;
|
||||
bool m_Free;
|
||||
int m_Follow;
|
||||
|
||||
CCamera();
|
||||
virtual void OnRender();
|
||||
virtual void OnConsoleInit();
|
||||
bool SetFollow(int Id);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <engine/graphics.h>
|
||||
#include <engine/textrender.h>
|
||||
|
@ -13,7 +11,6 @@
|
|||
|
||||
#include <game/client/components/scoreboard.h>
|
||||
#include <game/client/components/sounds.h>
|
||||
#include <game/client/components/camera.h>
|
||||
#include <game/localization.h>
|
||||
|
||||
#include "chat.h"
|
||||
|
@ -49,13 +46,11 @@ void CChat::OnStateChange(int NewState, int OldState)
|
|||
for(int i = 0; i < MAX_LINES; i++)
|
||||
m_aLines[i].m_Time = 0;
|
||||
m_CurrentLine = 0;
|
||||
m_ChatMoving = false;
|
||||
}
|
||||
}
|
||||
|
||||
void CChat::ConSay(IConsole::IResult *pResult, void *pUserData, int ClientID)
|
||||
{
|
||||
|
||||
((CChat*)pUserData)->Say(0, pResult->GetString(0));
|
||||
}
|
||||
|
||||
|
@ -79,22 +74,12 @@ void CChat::ConShowChat(IConsole::IResult *pResult, void *pUserData, int ClientI
|
|||
{
|
||||
((CChat *)pUserData)->m_Show = pResult->GetInteger(0) != 0;
|
||||
}
|
||||
void CChat::ConUpChat(IConsole::IResult *pResult, void *pUserData, int ClientID) {
|
||||
((CChat*)pUserData)->m_ChatMoving = true;
|
||||
((CChat*)pUserData)->m_RenderLine = (((CChat*)pUserData)->m_RenderLine - 1)%MAX_LINES;
|
||||
}
|
||||
|
||||
void CChat::ConDownChat(IConsole::IResult *pResult, void *pUserData, int ClientID) {
|
||||
((CChat*)pUserData)->m_ChatMoving = true;
|
||||
((CChat*)pUserData)->m_RenderLine = (((CChat*)pUserData)->m_RenderLine + 1)%MAX_LINES;
|
||||
}
|
||||
void CChat::OnConsoleInit()
|
||||
{
|
||||
Console()->Register("say", "r", CFGFLAG_CLIENT, ConSay, this, "Say in chat", 0);
|
||||
Console()->Register("say_team", "r", CFGFLAG_CLIENT, ConSayTeam, this, "Say in team chat", 0);
|
||||
Console()->Register("chat", "s", CFGFLAG_CLIENT, ConChat, this, "Enable chat with all/team mode", 0);
|
||||
Console()->Register("chat_up", "", CFGFLAG_CLIENT, ConUpChat, this, "Show early message", 0);
|
||||
Console()->Register("chat_down", "", CFGFLAG_CLIENT, ConDownChat, this, "Show last message", 0);
|
||||
Console()->Register("+show_chat", "", CFGFLAG_CLIENT, ConShowChat, this, "Show chat", 0);
|
||||
}
|
||||
|
||||
|
@ -174,15 +159,8 @@ void CChat::AddLine(int ClientId, int Team, const char *pLine)
|
|||
m_aLines[m_CurrentLine].m_NameColor = -2;
|
||||
|
||||
if(ClientId == -1) // server message
|
||||
{
|
||||
// Arrows
|
||||
if(g_Config.m_ClArrows && (strstr(pLine, " entered and joined the ")
|
||||
|| strstr(pLine, " has left the game") || strstr(pLine, " joined the ")))
|
||||
{
|
||||
str_copy(m_aLines[m_CurrentLine].m_aName, " ", sizeof(m_aLines[m_CurrentLine].m_aName));
|
||||
}
|
||||
else
|
||||
str_copy(m_aLines[m_CurrentLine].m_aName, "*** ", sizeof(m_aLines[m_CurrentLine].m_aName));
|
||||
{
|
||||
str_copy(m_aLines[m_CurrentLine].m_aName, "*** ", sizeof(m_aLines[m_CurrentLine].m_aName));
|
||||
str_format(m_aLines[m_CurrentLine].m_aText, sizeof(m_aLines[m_CurrentLine].m_aText), "%s", pLine);
|
||||
}
|
||||
else
|
||||
|
@ -212,10 +190,6 @@ void CChat::AddLine(int ClientId, int Team, const char *pLine)
|
|||
m_pClient->m_pSounds->Play(CSounds::CHN_GUI, SOUND_CHAT_CLIENT, 0, vec2(0,0));
|
||||
else
|
||||
m_pClient->m_pSounds->Play(CSounds::CHN_GUI, SOUND_CHAT_SERVER, 0, vec2(0,0));
|
||||
if (!m_ChatMoving) {
|
||||
m_RenderLine = m_CurrentLine;
|
||||
}
|
||||
m_ChatMoving = false;
|
||||
}
|
||||
|
||||
void CChat::OnRender()
|
||||
|
@ -252,15 +226,12 @@ void CChat::OnRender()
|
|||
float HeightLimit = m_pClient->m_pScoreboard->Active() ? 220.0f : m_Show ? 50.0f : 200.0f;
|
||||
for(int i = 0; i < MAX_LINES; i++)
|
||||
{
|
||||
int r = ((m_RenderLine-i)+MAX_LINES)%MAX_LINES;
|
||||
if(!m_Show && !m_ChatMoving) {
|
||||
if(Now > m_aLines[r].m_Time+15*time_freq())
|
||||
break;
|
||||
}
|
||||
|
||||
int r = ((m_CurrentLine-i)+MAX_LINES)%MAX_LINES;
|
||||
if(Now > m_aLines[r].m_Time+15*time_freq() && !m_Show)
|
||||
break;
|
||||
|
||||
float Begin = x;
|
||||
float FontSize = (float)g_Config.m_ClTextSize * 0.01f * 6.0f; // Text size factor
|
||||
float FontSize = 6.0f;
|
||||
|
||||
// get the y offset
|
||||
CTextCursor Cursor;
|
||||
|
@ -279,12 +250,7 @@ void CChat::OnRender()
|
|||
Cursor.m_LineWidth = LineWidth;
|
||||
|
||||
// render name
|
||||
CGameClient::CClientData currentData = m_pClient->m_aClients[m_aLines[r].m_ClientId];
|
||||
TextRender()->TextColor(
|
||||
(float)(m_PredefinedColors[m_aLines[r].m_ClientId].r)/255.0f,
|
||||
(float)(m_PredefinedColors[m_aLines[r].m_ClientId].g)/255.0f,
|
||||
(float)(m_PredefinedColors[m_aLines[r].m_ClientId].b)/255.0f,1);
|
||||
//TextRender()->TextColor(0.8f,0.8f,0.8f,1);//TODO: add colors at this strigng;
|
||||
TextRender()->TextColor(0.8f,0.8f,0.8f,1);
|
||||
if(m_aLines[r].m_ClientId == -1)
|
||||
TextRender()->TextColor(1,1,0.5f,1); // system
|
||||
else if(m_aLines[r].m_Team)
|
||||
|
@ -305,116 +271,8 @@ void CChat::OnRender()
|
|||
TextRender()->TextColor(1,1,0.5f,1); // system
|
||||
else if(m_aLines[r].m_Team)
|
||||
TextRender()->TextColor(0.65f,1,0.65f,1); // team message
|
||||
|
||||
const int txtsize = 12.0f*g_Config.m_ClTextSize/100;
|
||||
|
||||
// Arrows
|
||||
if(g_Config.m_ClArrows && m_aLines[r].m_ClientId == -1)
|
||||
{
|
||||
if(strstr(m_aLines[r].m_aText, " entered and joined the ")) // Asrrows for entering the game
|
||||
{
|
||||
if(strstr(m_aLines[r].m_aText, "blue team"))
|
||||
TextRender()->TextColor(0.7f,0.7f,1.0f,1); // blue
|
||||
|
||||
else if(strstr(m_aLines[r].m_aText, "red team"))
|
||||
TextRender()->TextColor(1.0f,0.5f,0.5f,1); // red
|
||||
|
||||
else if(strstr(m_aLines[r].m_aText, "spectators"))
|
||||
TextRender()->TextColor(0.80f,0.43f,0.80f, 1); // purple
|
||||
|
||||
else if(strstr(m_aLines[r].m_aText, "the game"))
|
||||
TextRender()->TextColor(0.8f,0.8f,0.4f,1);
|
||||
|
||||
|
||||
Graphics()->TextureSet(g_pData->m_aImages[IMAGE_ARROWS].m_Id);
|
||||
Graphics()->QuadsBegin();
|
||||
|
||||
RenderTools()->SelectSprite(SPRITE_ARROW_GREEN);
|
||||
|
||||
IGraphics::CQuadItem QuadItem(x+1, y-2+txtsize/2, 10, 10);
|
||||
Graphics()->QuadsDraw(&QuadItem, 1);
|
||||
|
||||
Graphics()->QuadsEnd();
|
||||
|
||||
char str[256];
|
||||
strcpy(str, m_aLines[r].m_aText);
|
||||
strcpy(strstr(str , " entered and joined the "), " ");
|
||||
TextRender()->TextEx(&Cursor, str, -1);
|
||||
}
|
||||
else if(strstr(m_aLines[r].m_aText, " has left the game")) // Dunedune arrows for quitting the game
|
||||
{
|
||||
Graphics()->TextureSet(g_pData->m_aImages[IMAGE_ARROWS].m_Id);
|
||||
TextRender()->TextColor(1.0f,0.57f,0.18f,1);
|
||||
|
||||
Graphics()->QuadsBegin();
|
||||
RenderTools()->SelectSprite(SPRITE_ARROW_RED);
|
||||
|
||||
IGraphics::CQuadItem QuadItem(x+1, y-2+txtsize/2, 10, 10);
|
||||
Graphics()->QuadsDraw(&QuadItem, 1);
|
||||
Graphics()->QuadsEnd();
|
||||
|
||||
char str[256];
|
||||
strcpy(str, m_aLines[r].m_aText);
|
||||
strcpy(strstr(str , " has left the game"), " ");
|
||||
TextRender()->TextEx(&Cursor, str, -1);
|
||||
}
|
||||
else if(strstr(m_aLines[r].m_aText, " joined the ")) // Dunedune arrows for switching team
|
||||
{
|
||||
int team = -1;
|
||||
if(strstr(m_aLines[r].m_aText, "blue team"))
|
||||
{
|
||||
TextRender()->TextColor(0.7f,0.7f,1.0f,1);
|
||||
team = 1;
|
||||
}
|
||||
else if(strstr(m_aLines[r].m_aText, "red team"))
|
||||
{
|
||||
TextRender()->TextColor(1.0f,0.5f,0.5f, 1);
|
||||
team = 0;
|
||||
}
|
||||
else if(strstr(m_aLines[r].m_aText, "spectators"))
|
||||
{
|
||||
TextRender()->TextColor(0.80f,0.43f,0.80f, 1);
|
||||
team = -1;
|
||||
}
|
||||
else if(strstr(m_aLines[r].m_aText, "the game"))
|
||||
{
|
||||
TextRender()->TextColor(0.8f,0.8f,0.4f,1);
|
||||
team = 2;
|
||||
}
|
||||
|
||||
Graphics()->TextureSet(g_pData->m_aImages[IMAGE_ARROWS].m_Id);
|
||||
|
||||
Graphics()->QuadsBegin();
|
||||
|
||||
if(team == -1)
|
||||
RenderTools()->SelectSprite(SPRITE_ARROW_SPEC);
|
||||
else
|
||||
{
|
||||
if(team == 1)
|
||||
RenderTools()->SelectSprite(SPRITE_ARROW_RIGHT);
|
||||
else if (team == 2)
|
||||
RenderTools()->SelectSprite(SPRITE_ARROW_JOIN);
|
||||
else if(!team)
|
||||
RenderTools()->SelectSprite(SPRITE_ARROW_LEFT);
|
||||
else
|
||||
RenderTools()->SelectSprite(SPRITE_ARROW_SPEC);
|
||||
}
|
||||
|
||||
IGraphics::CQuadItem QuadItem(x+1, (team == 0 || team == 1) ? y-1+txtsize : y-2+txtsize/2, 10, 10);
|
||||
Graphics()->QuadsDraw(&QuadItem, 1);
|
||||
|
||||
Graphics()->QuadsEnd();
|
||||
|
||||
char str[256];
|
||||
strcpy(str, m_aLines[r].m_aText);
|
||||
strcpy(strstr(str , " joined the "), " ");
|
||||
TextRender()->TextEx(&Cursor, str, -1);
|
||||
}
|
||||
else
|
||||
TextRender()->TextEx(&Cursor, m_aLines[r].m_aText, -1);
|
||||
}
|
||||
else
|
||||
TextRender()->TextEx(&Cursor, m_aLines[r].m_aText, -1);
|
||||
TextRender()->TextEx(&Cursor, m_aLines[r].m_aText, -1);
|
||||
}
|
||||
|
||||
TextRender()->TextColor(1,1,1,1);
|
||||
|
@ -422,17 +280,9 @@ void CChat::OnRender()
|
|||
|
||||
void CChat::Say(int Team, const char *pLine)
|
||||
{
|
||||
if(!str_comp_num(pLine, "/follow", 7) ) {
|
||||
int Num;
|
||||
if(sscanf(pLine, "/follow %d", &Num) == 1) {
|
||||
m_pClient->m_pCamera->SetFollow(Num);
|
||||
}
|
||||
} else {
|
||||
// send chat message
|
||||
CNetMsg_Cl_Say Msg;
|
||||
Msg.m_Team = Team;
|
||||
Msg.m_pMessage = pLine;
|
||||
Client()->SendPackMsg(&Msg, MSGFLAG_VITAL);
|
||||
}
|
||||
// send chat message
|
||||
CNetMsg_Cl_Say Msg;
|
||||
Msg.m_Team = Team;
|
||||
Msg.m_pMessage = pLine;
|
||||
Client()->SendPackMsg(&Msg, MSGFLAG_VITAL);
|
||||
}
|
||||
|
||||
|
|
|
@ -3,15 +3,15 @@
|
|||
#include <game/client/component.h>
|
||||
#include <game/client/lineinput.h>
|
||||
|
||||
enum
|
||||
{
|
||||
MAX_LINES = 25,
|
||||
};
|
||||
|
||||
class CChat : public CComponent
|
||||
{
|
||||
CLineInput m_Input;
|
||||
|
||||
enum
|
||||
{
|
||||
MAX_LINES = 25,
|
||||
};
|
||||
|
||||
struct CLine
|
||||
{
|
||||
int64 m_Time;
|
||||
|
@ -25,8 +25,6 @@ class CChat : public CComponent
|
|||
CLine m_aLines[MAX_LINES];
|
||||
int m_CurrentLine;
|
||||
|
||||
bool m_ChatMoving;
|
||||
|
||||
// chat
|
||||
enum
|
||||
{
|
||||
|
@ -42,13 +40,8 @@ class CChat : public CComponent
|
|||
static void ConSayTeam(IConsole::IResult *pResult, void *pUserData, int ClientID);
|
||||
static void ConChat(IConsole::IResult *pResult, void *pUserData, int ClientID);
|
||||
static void ConShowChat(IConsole::IResult *pResult, void *pUserData, int ClientID);
|
||||
static void ConUpChat(IConsole::IResult *pResult, void *pUserData, int ClientID);
|
||||
static void ConDownChat(IConsole::IResult *pResult, void *pUserData, int ClientID);
|
||||
|
||||
public:
|
||||
|
||||
int m_RenderLine;
|
||||
|
||||
CChat();
|
||||
|
||||
bool IsActive() const { return m_Mode != MODE_NONE; }
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
#include <game/client/component.h>
|
||||
#include <game/client/components/chat.h>
|
||||
#include <game/client/components/menus.h>
|
||||
#include <game/client/components/camera.h>
|
||||
|
||||
#include "controls.h"
|
||||
|
||||
|
@ -190,7 +189,7 @@ int CControls::SnapInput(int *pData)
|
|||
void CControls::OnRender()
|
||||
{
|
||||
// update target pos
|
||||
if(m_pClient->m_Snap.m_pGameobj && !(m_pClient->m_Snap.m_pGameobj->m_Paused || m_pClient->m_Snap.m_Spectate || m_pClient->m_pCamera->m_Free))
|
||||
if(m_pClient->m_Snap.m_pGameobj && !(m_pClient->m_Snap.m_pGameobj->m_Paused || m_pClient->m_Snap.m_Spectate))
|
||||
m_TargetPos = m_pClient->m_LocalCharacterPos + m_MousePos;
|
||||
}
|
||||
|
||||
|
@ -215,13 +214,13 @@ void CControls::ClampMousePos()
|
|||
|
||||
//vec2 camera_offset(0, 0);
|
||||
|
||||
if(m_pClient->m_Snap.m_Spectate || m_pClient->m_pCamera->m_Free)
|
||||
if(m_pClient->m_Snap.m_Spectate)
|
||||
{
|
||||
/*if(m_MousePos.x < 200.0f) m_MousePos.x = 200.0f;
|
||||
if(m_MousePos.x < 200.0f) m_MousePos.x = 200.0f;
|
||||
if(m_MousePos.y < 200.0f) m_MousePos.y = 200.0f;
|
||||
if(m_MousePos.x > Collision()->GetWidth()*32-200.0f) m_MousePos.x = Collision()->GetWidth()*32-200.0f;
|
||||
if(m_MousePos.y > Collision()->GetHeight()*32-200.0f) m_MousePos.y = Collision()->GetHeight()*32-200.0f;
|
||||
*/
|
||||
|
||||
m_TargetPos = m_MousePos;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
#include <stdio.h>
|
||||
|
||||
#include <engine/graphics.h>
|
||||
#include <engine/textrender.h>
|
||||
#include <engine/demo.h>
|
||||
#include <engine/shared/config.h>
|
||||
#include <engine/serverbrowser.h>
|
||||
|
||||
#include <game/generated/protocol.h>
|
||||
#include <game/generated/client_data.h>
|
||||
|
@ -18,25 +14,15 @@
|
|||
#include "hud.h"
|
||||
#include "voting.h"
|
||||
#include "binds.h"
|
||||
#include "menus.h"
|
||||
#include "race_demo.h"
|
||||
|
||||
CHud::CHud()
|
||||
{
|
||||
// won't work if zero
|
||||
m_AverageFPS = 1.0f;
|
||||
|
||||
OnReset();
|
||||
}
|
||||
|
||||
void CHud::OnReset()
|
||||
{
|
||||
m_CheckpointTick = 0;
|
||||
m_CheckpointDiff = 0;
|
||||
m_RaceTime = 0;
|
||||
m_Record = 0;
|
||||
m_LocalRecord = -1.0f;
|
||||
m_LastReceivedTimeTick = -1;
|
||||
}
|
||||
|
||||
void CHud::RenderGameTimer()
|
||||
|
@ -83,7 +69,7 @@ void CHud::RenderScoreHud()
|
|||
float Whole = 300*Graphics()->ScreenAspect();
|
||||
|
||||
// render small score hud
|
||||
if(!m_pClient->m_IsRace && !(m_pClient->m_Snap.m_pGameobj && m_pClient->m_Snap.m_pGameobj->m_GameOver) && (GameFlags&GAMEFLAG_TEAMS))
|
||||
if(!(m_pClient->m_Snap.m_pGameobj && m_pClient->m_Snap.m_pGameobj->m_GameOver) && (GameFlags&GAMEFLAG_TEAMS))
|
||||
{
|
||||
char aScoreTeam[2][32];
|
||||
str_format(aScoreTeam[0], sizeof(aScoreTeam)/2, "%d", m_pClient->m_Snap.m_pGameobj->m_TeamscoreRed);
|
||||
|
@ -321,140 +307,6 @@ void CHud::RenderHealthAndAmmo()
|
|||
Graphics()->QuadsEnd();
|
||||
}
|
||||
|
||||
void CHud::RenderSpeedmeter()
|
||||
{
|
||||
if(!g_Config.m_ClRenderSpeedmeter)
|
||||
return;
|
||||
|
||||
// We calculate the speed instead of getting it from character.velocity cause it's buggy when
|
||||
// walking in front of a wall or when using the ninja sword
|
||||
static float Speed;
|
||||
static vec2 OldPos;
|
||||
static const int SMOOTH_TABLE_SIZE = 16;
|
||||
static const int ACCEL_THRESHOLD = 25;
|
||||
static float SmoothTable[SMOOTH_TABLE_SIZE];
|
||||
static int SmoothIndex = 0;
|
||||
|
||||
SmoothTable[SmoothIndex] = distance(m_pClient->m_LocalCharacterPos, OldPos)/Client()->FrameTime();
|
||||
if(Client()->State() == IClient::STATE_DEMOPLAYBACK)
|
||||
{
|
||||
float Mult = DemoPlayer()->BaseInfo()->m_Speed;
|
||||
SmoothTable[SmoothIndex] /= Mult;
|
||||
}
|
||||
SmoothIndex = (SmoothIndex + 1) % SMOOTH_TABLE_SIZE;
|
||||
OldPos = m_pClient->m_LocalCharacterPos;
|
||||
Speed = 0;
|
||||
for(int i = 0; i < SMOOTH_TABLE_SIZE; i++)
|
||||
Speed += SmoothTable[i];
|
||||
Speed /= SMOOTH_TABLE_SIZE;
|
||||
|
||||
int t = (!m_pClient->m_IsRace && (m_pClient->m_Snap.m_pGameobj->m_Flags & GAMEFLAG_TEAMS))? -1 : 1;
|
||||
int LastIndex = SmoothIndex - 1;
|
||||
if(LastIndex < 0)
|
||||
LastIndex = SMOOTH_TABLE_SIZE - 1;
|
||||
|
||||
Graphics()->BlendNormal();
|
||||
Graphics()->TextureSet(-1);
|
||||
Graphics()->QuadsBegin();
|
||||
if(g_Config.m_ClSpeedmeterAccel && Speed - SmoothTable[LastIndex] > ACCEL_THRESHOLD)
|
||||
Graphics()->SetColor(0.6f, 0.1f, 0.1f, 0.25f);
|
||||
else if(g_Config.m_ClSpeedmeterAccel && Speed - SmoothTable[LastIndex] < -ACCEL_THRESHOLD)
|
||||
Graphics()->SetColor(0.1f, 0.6f, 0.1f, 0.25f);
|
||||
else
|
||||
Graphics()->SetColor(0.1, 0.1, 0.1, 0.25);
|
||||
RenderTools()->DrawRoundRect(m_Width-45, 245+t*20, 55, 18, 5.0f);
|
||||
Graphics()->QuadsEnd();
|
||||
|
||||
char aBuf[16];
|
||||
str_format(aBuf, sizeof(aBuf), "%.0f", Speed/10);
|
||||
TextRender()->Text(0, m_Width-5-TextRender()->TextWidth(0,12,aBuf,-1), 246+t*20, 12, aBuf, -1);
|
||||
}
|
||||
|
||||
void CHud::RenderTime()
|
||||
{
|
||||
if(!m_pClient->m_IsRace)
|
||||
return;
|
||||
|
||||
// check racestate
|
||||
if(m_pClient->m_pRaceDemo->GetRaceState() != CRaceDemo::RACE_FINISHED && m_LastReceivedTimeTick+Client()->GameTickSpeed()*2 < Client()->GameTick())
|
||||
{
|
||||
m_pClient->m_pRaceDemo->m_RaceState = CRaceDemo::RACE_NONE;
|
||||
return;
|
||||
}
|
||||
|
||||
if(m_RaceTime)
|
||||
{
|
||||
if(!m_FinishTime && m_pClient->m_pRaceDemo->GetRaceState() == CRaceDemo::RACE_FINISHED)
|
||||
m_FinishTime = m_pClient->m_pRaceDemo->GetFinishTime();
|
||||
|
||||
char aBuf[64];
|
||||
if(m_FinishTime)
|
||||
{
|
||||
str_format(aBuf, sizeof(aBuf), "Finish time: %02d:%05.2f", (int)m_FinishTime/60, m_FinishTime-((int)m_FinishTime/60*60));
|
||||
TextRender()->Text(0, 150*Graphics()->ScreenAspect()-TextRender()->TextWidth(0,12,aBuf,-1)/2, 20, 12, aBuf, -1);
|
||||
}
|
||||
else if(m_pClient->m_pRaceDemo->GetRaceState() == CRaceDemo::RACE_STARTED)
|
||||
{
|
||||
str_format(aBuf, sizeof(aBuf), "%02d:%02d.%d", m_RaceTime/60, m_RaceTime%60, m_RaceTick/10);
|
||||
TextRender()->Text(0, 150*Graphics()->ScreenAspect()-TextRender()->TextWidth(0,12,"00:00.00",-1)/2, 20, 12, aBuf, -1); // use fixed value for text width so its not shaky
|
||||
}
|
||||
|
||||
if(g_Config.m_ClShowCheckpointDiff && m_CheckpointTick+Client()->GameTickSpeed()*6 > Client()->GameTick())
|
||||
{
|
||||
str_format(aBuf, sizeof(aBuf), "%+5.2f", m_CheckpointDiff);
|
||||
|
||||
// calculate alpha (4 sec 1 than get lower the next 2 sec)
|
||||
float a = 1.0f;
|
||||
if(m_CheckpointTick+Client()->GameTickSpeed()*4 < Client()->GameTick() && m_CheckpointTick+Client()->GameTickSpeed()*6 > Client()->GameTick())
|
||||
{
|
||||
// lower the alpha slowly to blend text out
|
||||
a = ((float)(m_CheckpointTick+Client()->GameTickSpeed()*6) - (float)Client()->GameTick()) / (float)(Client()->GameTickSpeed()*2);
|
||||
}
|
||||
|
||||
if(m_CheckpointDiff > 0)
|
||||
TextRender()->TextColor(1.0f,0.5f,0.5f,a); // red
|
||||
else if(m_CheckpointDiff < 0)
|
||||
TextRender()->TextColor(0.5f,1.0f,0.5f,a); // green
|
||||
else if(!m_CheckpointDiff)
|
||||
TextRender()->TextColor(1,1,1,a); // white
|
||||
TextRender()->Text(0, 150*Graphics()->ScreenAspect()-TextRender()->TextWidth(0, 10, aBuf, -1)/2, 33, 10, aBuf, -1);
|
||||
|
||||
TextRender()->TextColor(1,1,1,1);
|
||||
}
|
||||
}
|
||||
m_RaceTick+=100/Client()->GameTickSpeed();
|
||||
|
||||
if(m_RaceTick >= 100)
|
||||
m_RaceTick = 0;
|
||||
}
|
||||
|
||||
void CHud::RenderRecord()
|
||||
{
|
||||
if(!m_pClient->m_IsRace)
|
||||
return;
|
||||
|
||||
if(m_Record > 0 && g_Config.m_ClShowServerRecord && g_Config.m_ClShowRecords)
|
||||
{
|
||||
char aBuf[64];
|
||||
str_format(aBuf, sizeof(aBuf), "Server best:");
|
||||
TextRender()->Text(0, 5, 40, 6, aBuf, -1);
|
||||
str_format(aBuf, sizeof(aBuf), "%02d:%05.2f", (int)m_Record/60, m_Record-((int)m_Record/60*60));
|
||||
TextRender()->Text(0, 53, 40, 6, aBuf, -1);
|
||||
}
|
||||
|
||||
if(m_pClient->m_pRaceDemo->m_Time && (m_LocalRecord == -1 || m_LocalRecord > m_pClient->m_pRaceDemo->m_Time))
|
||||
m_LocalRecord = m_pClient->m_pRaceDemo->m_Time;
|
||||
|
||||
if(m_LocalRecord > 0 && g_Config.m_ClShowLocalRecord && g_Config.m_ClShowRecords)
|
||||
{
|
||||
char aBuf[64];
|
||||
str_format(aBuf, sizeof(aBuf), "Personal best:");
|
||||
TextRender()->Text(0, 5, 47, 6, aBuf, -1);
|
||||
str_format(aBuf, sizeof(aBuf), "%02d:%05.2f", (int)m_LocalRecord/60, m_LocalRecord-((int)m_LocalRecord/60*60));
|
||||
TextRender()->Text(0, 53, 47, 6, aBuf, -1);
|
||||
}
|
||||
}
|
||||
|
||||
void CHud::OnRender()
|
||||
{
|
||||
if(!m_pClient->m_Snap.m_pGameobj)
|
||||
|
@ -467,11 +319,7 @@ void CHud::OnRender()
|
|||
Spectate = true;
|
||||
|
||||
if(m_pClient->m_Snap.m_pLocalCharacter && !Spectate && !(m_pClient->m_Snap.m_pGameobj && m_pClient->m_Snap.m_pGameobj->m_GameOver))
|
||||
{
|
||||
RenderHealthAndAmmo();
|
||||
RenderSpeedmeter();
|
||||
RenderTime();
|
||||
}
|
||||
|
||||
RenderGameTimer();
|
||||
RenderSuddenDeath();
|
||||
|
@ -482,44 +330,5 @@ void CHud::OnRender()
|
|||
RenderConnectionWarning();
|
||||
RenderTeambalanceWarning();
|
||||
RenderVoting();
|
||||
RenderRecord();
|
||||
RenderCursor();
|
||||
}
|
||||
|
||||
void CHud::OnMessage(int MsgType, void *pRawMsg)
|
||||
{
|
||||
if(MsgType == NETMSGTYPE_SV_RACETIME)
|
||||
{
|
||||
// activate racestate just in case
|
||||
m_pClient->m_pRaceDemo->m_RaceState = CRaceDemo::RACE_STARTED;
|
||||
|
||||
CNetMsg_Sv_RaceTime *pMsg = (CNetMsg_Sv_RaceTime *)pRawMsg;
|
||||
m_RaceTime = pMsg->m_Time;
|
||||
m_RaceTick = 0;
|
||||
|
||||
m_LastReceivedTimeTick = Client()->GameTick();
|
||||
|
||||
if(m_FinishTime)
|
||||
m_FinishTime = 0;
|
||||
|
||||
if(pMsg->m_Check)
|
||||
{
|
||||
m_CheckpointDiff = (float)pMsg->m_Check/100;
|
||||
m_CheckpointTick = Client()->GameTick();
|
||||
}
|
||||
}
|
||||
else if(MsgType == NETMSGTYPE_SV_KILLMSG)
|
||||
{
|
||||
CNetMsg_Sv_KillMsg *pMsg = (CNetMsg_Sv_KillMsg *)pRawMsg;
|
||||
if(pMsg->m_Victim == m_pClient->m_Snap.m_LocalCid)
|
||||
{
|
||||
m_CheckpointTick = 0;
|
||||
m_RaceTime = 0;
|
||||
}
|
||||
}
|
||||
else if(MsgType == NETMSGTYPE_SV_RECORD)
|
||||
{
|
||||
CNetMsg_Sv_Record *pMsg = (CNetMsg_Sv_Record *)pRawMsg;
|
||||
m_Record = (float)pMsg->m_Time/100;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,16 +7,6 @@ class CHud : public CComponent
|
|||
float m_Width;
|
||||
float m_AverageFPS;
|
||||
|
||||
// Race
|
||||
float m_CheckpointDiff;
|
||||
int m_RaceTime;
|
||||
int m_LastReceivedTimeTick;
|
||||
int m_CheckpointTick;
|
||||
int m_RaceTick;
|
||||
float m_FinishTime;
|
||||
float m_Record;
|
||||
float m_LocalRecord;
|
||||
|
||||
void RenderCursor();
|
||||
|
||||
void RenderFps();
|
||||
|
@ -28,9 +18,6 @@ class CHud : public CComponent
|
|||
void RenderSuddenDeath();
|
||||
void RenderScoreHud();
|
||||
void RenderWarmupTimer();
|
||||
void RenderSpeedmeter();
|
||||
void RenderTime();
|
||||
void RenderRecord();
|
||||
|
||||
void MapscreenToGroup(float CenterX, float CenterY, struct CMapItemGroup *PGroup);
|
||||
public:
|
||||
|
@ -38,7 +25,6 @@ public:
|
|||
|
||||
virtual void OnReset();
|
||||
virtual void OnRender();
|
||||
virtual void OnMessage(int MsgType, void *pRawMsg);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
CMapImages::CMapImages()
|
||||
{
|
||||
m_Count = 0;
|
||||
m_EntitiesTextures = -1;
|
||||
}
|
||||
|
||||
void CMapImages::OnMapLoad()
|
||||
|
@ -48,14 +47,3 @@ void CMapImages::OnMapLoad()
|
|||
}
|
||||
}
|
||||
|
||||
int CMapImages::GetEntities()
|
||||
{
|
||||
if(m_EntitiesTextures == -1)
|
||||
{
|
||||
m_EntitiesTextures = Graphics()->LoadTexture("editor/entities_clear.png", CImageInfo::FORMAT_AUTO, 0); // Dunedune: first try to load the clear entities
|
||||
if(m_EntitiesTextures == -1)
|
||||
m_EntitiesTextures = Graphics()->LoadTexture("editor/entities.png", CImageInfo::FORMAT_AUTO, 0); // Failed : load the std entities
|
||||
}
|
||||
return m_EntitiesTextures;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,13 +6,12 @@ class CMapImages : public CComponent
|
|||
{
|
||||
int m_aTextures[64];
|
||||
int m_Count;
|
||||
int m_EntitiesTextures;
|
||||
public:
|
||||
CMapImages();
|
||||
|
||||
int Get(int Index) const { return m_aTextures[Index]; }
|
||||
int Num() const { return m_Count; }
|
||||
int GetEntities(); // Dunedune
|
||||
|
||||
virtual void OnMapLoad();
|
||||
};
|
||||
|
||||
|
|
|
@ -27,11 +27,11 @@ void CMapLayers::OnInit()
|
|||
}
|
||||
|
||||
|
||||
void CMapLayers::MapScreenToGroup(float CenterX, float CenterY, CMapItemGroup *pGroup, float Zoom)
|
||||
void CMapLayers::MapScreenToGroup(float CenterX, float CenterY, CMapItemGroup *pGroup)
|
||||
{
|
||||
float Points[4];
|
||||
RenderTools()->MapscreenToWorld(CenterX, CenterY, pGroup->m_ParallaxX/100.0f, pGroup->m_ParallaxY/100.0f,
|
||||
pGroup->m_OffsetX, pGroup->m_OffsetY, Graphics()->ScreenAspect(), Zoom, Points);
|
||||
pGroup->m_OffsetX, pGroup->m_OffsetY, Graphics()->ScreenAspect(), 1.0f, Points);
|
||||
Graphics()->MapScreen(Points[0], Points[1], Points[2], Points[3]);
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,7 @@ void CMapLayers::OnRender()
|
|||
{
|
||||
// set clipping
|
||||
float Points[4];
|
||||
MapScreenToGroup(Center.x, Center.y, m_pLayers->GameGroup(), m_pClient->m_pCamera->m_Zoom);
|
||||
MapScreenToGroup(Center.x, Center.y, m_pLayers->GameGroup());
|
||||
Graphics()->GetScreen(&Points[0], &Points[1], &Points[2], &Points[3]);
|
||||
float x0 = (pGroup->m_ClipX - Points[0]) / (Points[2]-Points[0]);
|
||||
float y0 = (pGroup->m_ClipY - Points[1]) / (Points[3]-Points[1]);
|
||||
|
@ -95,7 +95,7 @@ void CMapLayers::OnRender()
|
|||
(int)((x1-x0)*Graphics()->ScreenWidth()), (int)((y1-y0)*Graphics()->ScreenHeight()));
|
||||
}
|
||||
|
||||
MapScreenToGroup(Center.x, Center.y, pGroup, m_pClient->m_pCamera->m_Zoom);
|
||||
MapScreenToGroup(Center.x, Center.y, pGroup);
|
||||
|
||||
for(int l = 0; l < pGroup->m_NumLayers; l++)
|
||||
{
|
||||
|
@ -127,7 +127,7 @@ void CMapLayers::OnRender()
|
|||
Render = true;
|
||||
}
|
||||
|
||||
if(Render && pLayer->m_Type == LAYERTYPE_TILES && Input()->KeyPressed(KEY_LCTRL) && Input()->KeyPressed(KEY_LSHIFT) && Input()->KeyDown(KEY_KP0) && g_Config.m_DbgLayers)
|
||||
if(Render && pLayer->m_Type == LAYERTYPE_TILES && Input()->KeyPressed(KEY_LCTRL) && Input()->KeyPressed(KEY_LSHIFT) && Input()->KeyDown(KEY_KP0))
|
||||
{
|
||||
CMapItemLayerTilemap *pTMap = (CMapItemLayerTilemap *)pLayer;
|
||||
CTile *pTiles = (CTile *)m_pLayers->Map()->GetData(pTMap->m_Data);
|
||||
|
@ -153,7 +153,7 @@ void CMapLayers::OnRender()
|
|||
}
|
||||
}
|
||||
|
||||
if(Render && !IsGameLayer && !g_Config.m_GfxClearFull || (g_Config.m_GfxClearFull && IsGameLayer))
|
||||
if(Render && !IsGameLayer)
|
||||
{
|
||||
//layershot_begin();
|
||||
|
||||
|
@ -161,12 +161,7 @@ void CMapLayers::OnRender()
|
|||
{
|
||||
CMapItemLayerTilemap *pTMap = (CMapItemLayerTilemap *)pLayer;
|
||||
if(pTMap->m_Image == -1)
|
||||
{
|
||||
if(!g_Config.m_GfxClearFull)
|
||||
Graphics()->TextureSet(-1);
|
||||
else
|
||||
Graphics()->TextureSet(m_pClient->m_pMapimages->GetEntities());
|
||||
}
|
||||
else
|
||||
Graphics()->TextureSet(m_pClient->m_pMapimages->Get(pTMap->m_Image));
|
||||
|
||||
|
@ -205,3 +200,4 @@ void CMapLayers::OnRender()
|
|||
// reset the screen like it was before
|
||||
Graphics()->MapScreen(Screen.x, Screen.y, Screen.w, Screen.h);
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ class CMapLayers : public CComponent
|
|||
CLayers *m_pLayers; // todo refactor: maybe remove it and access it through client*
|
||||
int m_Type;
|
||||
|
||||
void MapScreenToGroup(float CenterX, float CenterY, CMapItemGroup *pGroup, float Zoom);
|
||||
void MapScreenToGroup(float CenterX, float CenterY, CMapItemGroup *pGroup);
|
||||
static void EnvelopeEval(float TimeOffset, int Env, float *pChannels, void *pUser);
|
||||
public:
|
||||
enum
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
#include "menus.h"
|
||||
#include "skins.h"
|
||||
|
||||
#include <string>
|
||||
#include <string.h>
|
||||
#include <engine/graphics.h>
|
||||
#include <engine/textrender.h>
|
||||
#include <engine/serverbrowser.h>
|
||||
|
@ -99,23 +97,9 @@ CMenus::CMenus()
|
|||
|
||||
m_LastInput = time_get();
|
||||
|
||||
m_Download.m_ElapsedTick = 50;
|
||||
m_Download.m_ElapsedSec = 0;
|
||||
m_Download.m_Speed = 0;
|
||||
m_Download.m_TimeNeeded = 0;
|
||||
m_Download.m_TimeRemaining = 0;
|
||||
|
||||
str_copy(m_aCurrentDemoFolder, "demos", sizeof(m_aCurrentDemoFolder));
|
||||
}
|
||||
|
||||
void CMenus::ResetDownloadVars() {
|
||||
m_Download.m_ElapsedTick = 50;
|
||||
m_Download.m_ElapsedSec = 0;
|
||||
m_Download.m_Speed = 0;
|
||||
m_Download.m_TimeNeeded = 0;
|
||||
m_Download.m_TimeRemaining = 0;
|
||||
}
|
||||
|
||||
vec4 CMenus::ButtonColorMul(const void *pID)
|
||||
{
|
||||
if(UI()->ActiveItem() == pID)
|
||||
|
@ -606,17 +590,8 @@ int CMenus::RenderMenubar(CUIRect r)
|
|||
static int s_CallVoteButton=0;
|
||||
if(DoButton_MenuTab(&s_CallVoteButton, Localize("Call vote"), m_ActivePage==PAGE_CALLVOTE, &Button, CUI::CORNER_T))
|
||||
NewPage = PAGE_CALLVOTE;
|
||||
|
||||
if(Client()->RconAuthed()) {
|
||||
Box.VSplitLeft(4.0f, 0, &Box);
|
||||
Box.VSplitLeft(100.0f, &Button, &Box);
|
||||
static int s_RCONButton=0;
|
||||
if(DoButton_MenuTab(&s_RCONButton, Localize("RCON"), m_ActivePage==PAGE_RCON, &Button, CUI::CORNER_T))
|
||||
NewPage = PAGE_RCON;
|
||||
|
||||
Box.VSplitLeft(30.0f, 0, &Box);
|
||||
}
|
||||
|
||||
|
||||
Box.VSplitLeft(30.0f, 0, &Box);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -835,9 +810,6 @@ int CMenus::Render()
|
|||
RenderServerControl(MainView);
|
||||
else if(m_GamePage == PAGE_SETTINGS)
|
||||
RenderSettings(MainView);
|
||||
else if(m_GamePage == PAGE_RCON)
|
||||
RenderRCON(MainView);
|
||||
|
||||
}
|
||||
else if(g_Config.m_UiPage == PAGE_NEWS)
|
||||
RenderNews(MainView);
|
||||
|
@ -851,23 +823,18 @@ int CMenus::Render()
|
|||
RenderServerbrowser(MainView);
|
||||
else if(g_Config.m_UiPage == PAGE_SETTINGS)
|
||||
RenderSettings(MainView);
|
||||
ResetDownloadVars();
|
||||
}
|
||||
else
|
||||
{
|
||||
// make sure that other windows doesn't do anything funnay!
|
||||
//UI()->SetHotItem(0);
|
||||
//UI()->SetActiveItem(0);
|
||||
char aBuf[512];
|
||||
char aBuf2[256];
|
||||
char aBuf3[128];
|
||||
std::string BufString;
|
||||
char aBuf[128];
|
||||
const char *pTitle = "";
|
||||
const char *pExtraText = "";
|
||||
const char *pButtonText = "";
|
||||
const char *pFooterText = "";
|
||||
int ExtraAlign = 0;
|
||||
bool FooterTextUse = false;
|
||||
|
||||
if(m_Popup == POPUP_MESSAGE)
|
||||
{
|
||||
pTitle = m_aMessageTopic;
|
||||
|
@ -881,124 +848,9 @@ int CMenus::Render()
|
|||
pButtonText = Localize("Abort");
|
||||
if(Client()->MapDownloadTotalsize() > 0)
|
||||
{
|
||||
/*
|
||||
pTitle = Localize("Downloading map");
|
||||
str_format(aBuf, sizeof(aBuf), "%d/%d KiB", Client()->MapDownloadAmount()/1024, Client()->MapDownloadTotalsize()/1024);
|
||||
pExtraText = aBuf;
|
||||
*/
|
||||
// Ticks
|
||||
if(m_Download.m_ElapsedTick <= 0)
|
||||
{
|
||||
m_Download.m_ElapsedSec++;
|
||||
m_Download.m_ElapsedTick = 50;
|
||||
// Calc Speed
|
||||
m_Download.m_Speed = Client()->MapDownloadAmount()/1024 - m_Download.m_LastSize;
|
||||
/* download.speed = (float)client_mapdownload_amount()/1024/download.timeneeded; */ // OLD CALC SYS
|
||||
|
||||
m_Download.m_LastSize = Client()->MapDownloadAmount()/1024;
|
||||
}
|
||||
else if(m_Download.m_ElapsedTick > 0)
|
||||
m_Download.m_ElapsedTick--;
|
||||
|
||||
// Time elapsed
|
||||
m_Download.m_TimeNeeded = (float)m_Download.m_ElapsedSec + (50-m_Download.m_ElapsedTick)/50.0;
|
||||
|
||||
// Calc Time remaining
|
||||
if(m_Download.m_Speed != 0.0)
|
||||
m_Download.m_TimeRemaining = ((float)Client()->MapDownloadTotalsize()/1024-Client()->MapDownloadAmount()/1024)/m_Download.m_Speed;
|
||||
else
|
||||
m_Download.m_TimeRemaining = 0;
|
||||
|
||||
// Check for negativ values, set them to 0
|
||||
if(m_Download.m_Speed < 0.0)
|
||||
m_Download.m_Speed = 0;
|
||||
if(m_Download.m_TimeNeeded < 0.0)
|
||||
m_Download.m_TimeNeeded = 0;
|
||||
if(m_Download.m_TimeRemaining < 0.0)
|
||||
m_Download.m_TimeRemaining = 0;
|
||||
|
||||
// Set the texts
|
||||
str_format(aBuf2, sizeof(aBuf2),"Downloading map '%s'", Client()->MapDownloadName());
|
||||
char aBufForParam[50];
|
||||
char aBufForNum[20];
|
||||
const int end = 32;
|
||||
if(g_Config.m_ClDownloadExtensionStatusPercent)
|
||||
{
|
||||
str_format(aBufForParam, sizeof(aBufForParam), "Status....................");
|
||||
str_format(aBufForNum, sizeof(aBufForNum), ": %3.2f%%\n", ((float)Client()->MapDownloadAmount()/1024.0*100.0)/((float)Client()->MapDownloadTotalsize()/1024.0));
|
||||
int lenOfParam = strlen(aBufForNum);
|
||||
for(int i = end, j = lenOfParam; j >= 0; --j, --i) {
|
||||
aBufForParam[i] = aBufForNum[j];
|
||||
}
|
||||
BufString += aBufForParam;
|
||||
}
|
||||
if(g_Config.m_ClDownloadExtensionSize)
|
||||
{
|
||||
str_format(aBufForParam, sizeof(aBufForParam), "Size......................");
|
||||
str_format(aBufForNum, sizeof(aBufForNum), ": %d/%d KiB\n", Client()->MapDownloadAmount()/1024, Client()->MapDownloadTotalsize()/1024);
|
||||
int lenOfParam = strlen(aBufForNum);
|
||||
for(int i = end, j = lenOfParam; j >= 0; --j, --i) {
|
||||
aBufForParam[i] = aBufForNum[j];
|
||||
}
|
||||
BufString += aBufForParam;
|
||||
}
|
||||
if(g_Config.m_ClDownloadExtensionSpeed)
|
||||
{
|
||||
str_format(aBufForParam, sizeof(aBufForParam), "Download speed............");
|
||||
str_format(aBufForNum, sizeof(aBufForNum), ": %3.1f KiB/s\n", m_Download.m_Speed);
|
||||
int lenOfParam = strlen(aBufForNum);
|
||||
for(int i = end, j = lenOfParam; j >= 0; --j, --i) {
|
||||
aBufForParam[i] = aBufForNum[j];
|
||||
}
|
||||
BufString += aBufForParam;
|
||||
}
|
||||
if(g_Config.m_ClDownloadExtensionTimeElapsed)
|
||||
{
|
||||
str_format(aBufForParam, sizeof(aBufForParam), "Time elapsed..............");
|
||||
str_format(aBufForNum, sizeof(aBufForNum), ": %3.1f sec\n", m_Download.m_TimeNeeded);
|
||||
int lenOfParam = strlen(aBufForNum);
|
||||
for(int i = end, j = lenOfParam; j >= 0; --j, --i) {
|
||||
aBufForParam[i] = aBufForNum[j];
|
||||
}
|
||||
BufString += aBufForParam;
|
||||
}
|
||||
if(g_Config.m_ClDownloadExtensionTimeRemaining)
|
||||
{
|
||||
str_format(aBufForParam, sizeof(aBufForParam), "Time remaining............");
|
||||
str_format(aBufForNum, sizeof(aBufForNum), ": %3.1f sec", m_Download.m_TimeRemaining);
|
||||
int lenOfParam = strlen(aBufForNum);
|
||||
for(int i = end, j = lenOfParam + 1; j >= 0; --j, --i) {
|
||||
aBufForParam[i] = aBufForNum[j];
|
||||
}
|
||||
BufString += aBufForParam;
|
||||
}
|
||||
|
||||
pTitle = aBuf2;
|
||||
pExtraText = BufString.c_str();
|
||||
ExtraAlign = 0;
|
||||
// START - Render Status Bar
|
||||
if(g_Config.m_ClDownloadExtensionStatusBar)
|
||||
{
|
||||
CUIRect Screen = *UI()->Screen();
|
||||
|
||||
Graphics()->MapScreen(Screen.x, Screen.y, Screen.w, Screen.h);
|
||||
|
||||
float w = 700;
|
||||
float h = 200;
|
||||
float x = Screen.w/2-w/2;
|
||||
float y = Screen.h/2-h/2;
|
||||
|
||||
Graphics()->TextureSet(-1);
|
||||
Graphics()->QuadsBegin();
|
||||
Graphics()->SetColor(g_Config.m_ClDownloadExtensionStatusBar_r/255.0f, g_Config.m_ClDownloadExtensionStatusBar_g/255.0f, g_Config.m_ClDownloadExtensionStatusBar_b/255.0f, g_Config.m_ClDownloadExtensionStatusBar_a/255.0f);
|
||||
RenderTools()->DrawRoundRect(x+40, y+h-75+20, (w-80)*(Client()->MapDownloadAmount()/1024*100)/(Client()->MapDownloadTotalsize()/1024)/100, 25, 5.0f);
|
||||
Graphics()->QuadsEnd();
|
||||
}
|
||||
// END - Render Staus Bar
|
||||
|
||||
// Mod By KillaBilla
|
||||
//footer_text = "DownloadExtension Mod\nVersion: 1.3\nMod by KillaBilla";
|
||||
//footer_text_use = true;
|
||||
}
|
||||
}
|
||||
else if(m_Popup == POPUP_DISCONNECTED)
|
||||
|
@ -1040,7 +892,7 @@ int CMenus::Render()
|
|||
ExtraAlign = -1;
|
||||
}
|
||||
|
||||
CUIRect Box, Part, Text;
|
||||
CUIRect Box, Part;
|
||||
Box = Screen;
|
||||
Box.VMargin(150.0f, &Box);
|
||||
Box.HMargin(150.0f, &Box);
|
||||
|
@ -1174,7 +1026,6 @@ int CMenus::Render()
|
|||
m_Popup = POPUP_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -106,7 +106,6 @@ class CMenus : public CComponent
|
|||
PAGE_GAME,
|
||||
PAGE_SERVER_INFO,
|
||||
PAGE_CALLVOTE,
|
||||
PAGE_RCON,
|
||||
PAGE_INTERNET,
|
||||
PAGE_LAN,
|
||||
PAGE_FAVORITES,
|
||||
|
@ -153,7 +152,7 @@ class CMenus : public CComponent
|
|||
// for call vote
|
||||
int m_CallvoteSelectedOption;
|
||||
int m_CallvoteSelectedPlayer;
|
||||
int m_RCONSelectedPlayer;
|
||||
|
||||
// demo
|
||||
struct CDemoItem
|
||||
{
|
||||
|
@ -163,9 +162,11 @@ class CMenus : public CComponent
|
|||
bool operator<(const CDemoItem &Other) { return str_comp(m_aName, Other.m_aName) < 0; }
|
||||
};
|
||||
|
||||
sorted_array<CDemoItem> m_lDemos;
|
||||
char m_aCurrentDemoFolder[256];
|
||||
bool m_DemolistDelEntry;
|
||||
|
||||
void DemolistPopulate();
|
||||
static void DemolistFetchCallback(const char *pName, int IsDir, int DirType, void *pUser);
|
||||
|
||||
// found in menus.cpp
|
||||
|
@ -186,9 +187,6 @@ class CMenus : public CComponent
|
|||
void RenderServerControlKick(CUIRect MainView);
|
||||
void RenderServerControlServer(CUIRect MainView);
|
||||
|
||||
// found in menus_rcon.cpp
|
||||
void RenderRCON(CUIRect MainView);
|
||||
|
||||
// found in menus_browser.cpp
|
||||
int m_SelectedIndex;
|
||||
void RenderServerbrowserServerList(CUIRect View);
|
||||
|
@ -203,13 +201,9 @@ class CMenus : public CComponent
|
|||
void RenderSettingsControls(CUIRect MainView);
|
||||
void RenderSettingsGraphics(CUIRect MainView);
|
||||
void RenderSettingsSound(CUIRect MainView);
|
||||
void RenderSettingsDownloadExtension(CUIRect MainView);
|
||||
void RenderSettingsRace(CUIRect MainView);
|
||||
void RenderSettings(CUIRect MainView);
|
||||
|
||||
void SetActive(bool Active);
|
||||
|
||||
void ResetDownloadVars();
|
||||
public:
|
||||
void RenderBackground();
|
||||
|
||||
|
@ -217,16 +211,6 @@ public:
|
|||
|
||||
static CMenusKeyBinder m_Binder;
|
||||
|
||||
struct
|
||||
{
|
||||
int m_ElapsedSec;
|
||||
int m_ElapsedTick;
|
||||
float m_Speed;
|
||||
float m_TimeNeeded;
|
||||
int m_LastSize;
|
||||
float m_TimeRemaining;
|
||||
} m_Download;
|
||||
|
||||
CMenus();
|
||||
|
||||
void RenderLoading(float Percent);
|
||||
|
@ -240,8 +224,5 @@ public:
|
|||
virtual void OnRender();
|
||||
virtual bool OnInput(IInput::CEvent Event);
|
||||
virtual bool OnMouseMove(float x, float y);
|
||||
|
||||
sorted_array<CDemoItem> m_lDemos;
|
||||
void DemolistPopulate();
|
||||
};
|
||||
#endif
|
||||
|
|
|
@ -1,133 +0,0 @@
|
|||
|
||||
#include <base/math.h>
|
||||
|
||||
|
||||
#include <engine/serverbrowser.h>
|
||||
#include <engine/textrender.h>
|
||||
#include <engine/shared/config.h>
|
||||
|
||||
#include <game/generated/protocol.h>
|
||||
#include <game/generated/client_data.h>
|
||||
|
||||
#include <game/client/ui.h>
|
||||
#include <game/client/gameclient.h>
|
||||
#include <game/client/animstate.h>
|
||||
#include <game/localization.h>
|
||||
|
||||
#include "menus.h"
|
||||
#include "motd.h"
|
||||
#include "voting.h"
|
||||
|
||||
void CMenus::RenderRCON(CUIRect MainView)
|
||||
{
|
||||
CUIRect ButtonBar;
|
||||
//
|
||||
RenderTools()->DrawUIRect(&MainView, ms_ColorTabbarActive, CUI::CORNER_ALL, 10.0f);
|
||||
|
||||
//TabBar.HSplitTop(50.0f, &Temp, &TabBar);
|
||||
//RenderTools()->DrawUIRect(&Temp, ms_ColorTabbarActive, CUI::CORNER_R, 10.0f);
|
||||
|
||||
MainView.Margin(10.00f, &MainView);
|
||||
|
||||
MainView.VSplitRight(150.0f, &MainView, &ButtonBar);
|
||||
|
||||
CUIRect ButtonKick;
|
||||
CUIRect ButtonMute;
|
||||
//CUIRect ButtonUnMute;
|
||||
CUIRect ButtonKill;
|
||||
CUIRect ButtonBan;
|
||||
|
||||
ButtonBar.VMargin(10.0f, &ButtonBar);
|
||||
|
||||
|
||||
CUIRect ButtonBar1, ButtonBar2, ButtonBar3, ButtonBar4, ButtonBar5;
|
||||
ButtonBar.HSplitTop(30.0f, &ButtonKick, &ButtonBar1);
|
||||
ButtonBar1.HMargin(10.0f, &ButtonBar1);
|
||||
ButtonBar1.HSplitTop(30.0f, &ButtonMute, &ButtonBar2);
|
||||
ButtonBar2.HMargin(10.0f, &ButtonBar2);
|
||||
ButtonBar2.HSplitTop(30.0f, &ButtonKill, &ButtonBar3);
|
||||
ButtonBar3.HMargin(10.0f, &ButtonBar3);
|
||||
ButtonBar3.HSplitTop(30.0f, &ButtonBan, &ButtonBar4);
|
||||
//MainView.VSplitLeft(5.0f, &ButtonBar, &ButtonMute);
|
||||
//MainView.VSplitLeft(5.0f, &ButtonBar, &ButtonUnMute);
|
||||
//MainView.VSplitLeft(5.0f, &ButtonBar, &ButtonKill);
|
||||
//MainView.VSplitLeft(5.0f, &ButtonBar, &ButtonBan);
|
||||
|
||||
|
||||
|
||||
int NumOptions = 0;
|
||||
int Selected = -1;
|
||||
static int aPlayerIDs[MAX_CLIENTS];
|
||||
for(int i = 0; i < MAX_CLIENTS; i++)
|
||||
{
|
||||
if(!m_pClient->m_Snap.m_paPlayerInfos[i])
|
||||
continue;
|
||||
if(m_RCONSelectedPlayer == i)
|
||||
Selected = NumOptions;
|
||||
aPlayerIDs[NumOptions++] = i;
|
||||
}
|
||||
|
||||
static int s_VoteList = 0;
|
||||
static float s_ScrollValue = 0;
|
||||
CUIRect List = MainView;
|
||||
UiDoListboxStart(&s_VoteList, &List, 24.0f, Localize("Players"), "", NumOptions, 1, Selected, s_ScrollValue);
|
||||
|
||||
for(int i = 0; i < NumOptions; i++)
|
||||
{
|
||||
CListboxItem Item = UiDoListboxNextItem(&aPlayerIDs[i]);
|
||||
|
||||
if(Item.m_Visible)
|
||||
{
|
||||
CTeeRenderInfo Info = m_pClient->m_aClients[aPlayerIDs[i]].m_RenderInfo;
|
||||
Info.m_Size = Item.m_Rect.h;
|
||||
Item.m_Rect.HSplitTop(5.0f, 0, &Item.m_Rect); // some margin from the top
|
||||
RenderTools()->RenderTee(CAnimState::GetIdle(), &Info, EMOTE_NORMAL, vec2(1,0), vec2(Item.m_Rect.x+Item.m_Rect.h/2, Item.m_Rect.y+Item.m_Rect.h/2));
|
||||
Item.m_Rect.x +=Info.m_Size;
|
||||
UI()->DoLabel(&Item.m_Rect, m_pClient->m_aClients[aPlayerIDs[i]].m_aName, 16.0f, -1);
|
||||
}
|
||||
}
|
||||
|
||||
Selected = UiDoListboxEnd(&s_ScrollValue, 0);
|
||||
m_RCONSelectedPlayer = Selected != -1 ? aPlayerIDs[Selected] : -1;
|
||||
static int s_KickButton = 0;
|
||||
char buf[512];
|
||||
if(DoButton_Menu(&s_KickButton, Localize("Kick"), 0, &ButtonKick))
|
||||
{
|
||||
if(m_RCONSelectedPlayer >= 0 && m_RCONSelectedPlayer < MAX_CLIENTS) {
|
||||
|
||||
|
||||
str_format(buf, sizeof(buf), "rcon kick %d", m_RCONSelectedPlayer);
|
||||
m_pClient->Console()->ExecuteLine(buf, 4, -1);
|
||||
}
|
||||
}
|
||||
static int s_KillButton = 0;
|
||||
if(DoButton_Menu(&s_KillButton, Localize("Kill"), 0, &ButtonKill))
|
||||
{
|
||||
if(m_RCONSelectedPlayer >= 0 && m_RCONSelectedPlayer < MAX_CLIENTS) {
|
||||
|
||||
|
||||
str_format(buf, sizeof(buf), "rcon kill_pl %d", m_RCONSelectedPlayer);
|
||||
m_pClient->Console()->ExecuteLine(buf, 4, -1);
|
||||
}
|
||||
}
|
||||
static int s_MuteButton = 0;
|
||||
if(DoButton_Menu(&s_MuteButton, Localize("Mute"), 0, &ButtonMute))
|
||||
{
|
||||
if(m_RCONSelectedPlayer >= 0 && m_RCONSelectedPlayer < MAX_CLIENTS) {
|
||||
|
||||
|
||||
str_format(buf, sizeof(buf), "rcon mute %d 100", m_RCONSelectedPlayer);
|
||||
m_pClient->Console()->ExecuteLine(buf, 4, -1);
|
||||
}
|
||||
}
|
||||
static int s_BanButton = 0;
|
||||
if(DoButton_Menu(&s_BanButton, Localize("Ban"), 0, &ButtonBan))
|
||||
{
|
||||
if(m_RCONSelectedPlayer >= 0 && m_RCONSelectedPlayer < MAX_CLIENTS) {
|
||||
|
||||
|
||||
str_format(buf, sizeof(buf), "rcon ban %d 300", m_RCONSelectedPlayer);
|
||||
m_pClient->Console()->ExecuteLine(buf, 4, -1);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -636,147 +636,6 @@ void CMenus::RenderSettingsSound(CUIRect MainView)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void CMenus::RenderSettingsDownloadExtension(CUIRect MainView)
|
||||
{
|
||||
CUIRect button, text, reset_button;
|
||||
MainView.HSplitTop(10.0f, &text, &MainView);
|
||||
UI()->DoLabel(&text, "Download Extension", 40.0f, -1);
|
||||
MainView.HSplitTop(40.0f, 0, &MainView);
|
||||
MainView.HSplitTop(10.0f, &text, &MainView);
|
||||
UI()->DoLabel(&text, "Version: 1.3", 15.0f, -1);
|
||||
MainView.HSplitTop(10.0f, 0, &MainView);
|
||||
MainView.HSplitTop(10.0f, &text, &MainView);
|
||||
UI()->DoLabel(&text, "Mod by KillaBilla", 15.0f, -1);
|
||||
MainView.HSplitTop(20.0f, 0, &MainView);
|
||||
MainView.HSplitTop(10.0f, &text, &MainView);
|
||||
MainView.HSplitTop(20.0f, &button, &MainView);
|
||||
if(DoButton_CheckBox(&g_Config.m_ClDownloadExtensionStatusPercent, "Show status in percent", g_Config.m_ClDownloadExtensionStatusPercent, &button))
|
||||
g_Config.m_ClDownloadExtensionStatusPercent ^= 1;
|
||||
MainView.HSplitTop(20.0f, &button, &MainView);
|
||||
if(DoButton_CheckBox(&g_Config.m_ClDownloadExtensionSize, "Show map size", g_Config.m_ClDownloadExtensionSize, &button))
|
||||
g_Config.m_ClDownloadExtensionSize ^= 1;
|
||||
MainView.HSplitTop(20.0f, &button, &MainView);
|
||||
if(DoButton_CheckBox(&g_Config.m_ClDownloadExtensionSpeed, "Show download speed", g_Config.m_ClDownloadExtensionSpeed, &button))
|
||||
g_Config.m_ClDownloadExtensionSpeed ^= 1;
|
||||
MainView.HSplitTop(20.0f, &button, &MainView);
|
||||
if(DoButton_CheckBox(&g_Config.m_ClDownloadExtensionTimeElapsed, "Show time elapsed", g_Config.m_ClDownloadExtensionTimeElapsed, &button))
|
||||
g_Config.m_ClDownloadExtensionTimeElapsed ^= 1;
|
||||
MainView.HSplitTop(20.0f, &button, &MainView);
|
||||
if(DoButton_CheckBox(&g_Config.m_ClDownloadExtensionTimeRemaining, "Show time remaiming", g_Config.m_ClDownloadExtensionTimeRemaining, &button))
|
||||
g_Config.m_ClDownloadExtensionTimeRemaining ^= 1;
|
||||
MainView.HSplitTop(20.0f, &button, &MainView);
|
||||
if(DoButton_CheckBox(&g_Config.m_ClDownloadExtensionStatusBar, "Show progress bar", g_Config.m_ClDownloadExtensionStatusBar, &button))
|
||||
g_Config.m_ClDownloadExtensionStatusBar ^= 1;
|
||||
MainView.HSplitTop(20.0f, &button, &MainView);
|
||||
MainView.HSplitTop(30.0f, &text, &MainView);
|
||||
UI()->DoLabel(&text, "Progress bar color:", 25.0f, -1);
|
||||
MainView.HSplitTop(20.0f, 0, &MainView);
|
||||
const char *labels[] = {"Red", "Green", "Blue", "Alpha"};
|
||||
int *color_slider[4] = {&g_Config.m_ClDownloadExtensionStatusBar_r, &g_Config.m_ClDownloadExtensionStatusBar_g, &g_Config.m_ClDownloadExtensionStatusBar_b, &g_Config.m_ClDownloadExtensionStatusBar_a};
|
||||
for(int s = 0; s < 4; s++)
|
||||
{
|
||||
CUIRect text;
|
||||
MainView.HSplitTop(19.0f, &button, &MainView);
|
||||
button.VMargin(15.0f, &button);
|
||||
button.VSplitLeft(50.0f, &text, &button);
|
||||
button.VSplitRight(5.0f, &button, 0);
|
||||
button.HSplitTop(4.0f, 0, &button);
|
||||
|
||||
float k = (*color_slider[s]) / 255.0f;
|
||||
k = DoScrollbarH(color_slider[s], &button, k);
|
||||
*color_slider[s] = (int)(k*255.0f);
|
||||
UI()->DoLabel(&text, labels[s], 15.0f, -1);
|
||||
}
|
||||
MainView.HSplitTop(30.0f, &button, &MainView);
|
||||
button.HSplitBottom(20.0f, 0, &button);
|
||||
RenderTools()->DrawUIRect(&button, vec4(g_Config.m_ClDownloadExtensionStatusBar_r/255.0, g_Config.m_ClDownloadExtensionStatusBar_g/255.0, g_Config.m_ClDownloadExtensionStatusBar_b/255.0, g_Config.m_ClDownloadExtensionStatusBar_a/255.0), 0, 5.0f);
|
||||
|
||||
// Defaults
|
||||
CUIRect ResetButton;
|
||||
MainView.HSplitTop(40.0f, 0, &MainView);
|
||||
MainView.HSplitTop(40.0f, &ResetButton, &MainView);
|
||||
//MainView.VSplitRight(40.0f, &ResetButton, &MainView);
|
||||
static int DefaultButton = 0;
|
||||
|
||||
if (DoButton_Menu((void*)&DefaultButton, "Reset to defaults", 0, &ResetButton))
|
||||
{
|
||||
g_Config.m_ClDownloadExtensionStatusPercent = 1;
|
||||
g_Config.m_ClDownloadExtensionSize = 1;
|
||||
g_Config.m_ClDownloadExtensionSpeed = 1;
|
||||
g_Config.m_ClDownloadExtensionTimeElapsed = 1;
|
||||
g_Config.m_ClDownloadExtensionTimeRemaining = 1;
|
||||
g_Config.m_ClDownloadExtensionStatusBar = 1;
|
||||
g_Config.m_ClDownloadExtensionStatusBar_r = 255;
|
||||
g_Config.m_ClDownloadExtensionStatusBar_g = 255;
|
||||
g_Config.m_ClDownloadExtensionStatusBar_b = 255;
|
||||
g_Config.m_ClDownloadExtensionStatusBar_a = 191;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void CMenus::RenderSettingsRace(CUIRect MainView)
|
||||
{
|
||||
CUIRect Button;
|
||||
CUIRect LeftView, RightView;
|
||||
|
||||
MainView.VSplitMid(&LeftView, &RightView);
|
||||
|
||||
// Left
|
||||
LeftView.HSplitTop(20.0f, &Button, &LeftView);
|
||||
UI()->DoLabel(&Button, Localize("Race specific settings"), 14.0f, -1);
|
||||
|
||||
LeftView.HSplitTop(20.0f, &Button, &LeftView);
|
||||
if(DoButton_CheckBox(&g_Config.m_ClAutoRecord, Localize("Auto record"), g_Config.m_ClAutoRecord, &Button))
|
||||
g_Config.m_ClAutoRecord ^= 1;
|
||||
|
||||
LeftView.HSplitTop(20.0f, &Button, &LeftView);
|
||||
if(DoButton_CheckBox(&g_Config.m_ClShowOthers, Localize("Show other players"), g_Config.m_ClShowOthers, &Button))
|
||||
g_Config.m_ClShowOthers ^= 1;
|
||||
|
||||
LeftView.HSplitTop(20.0f, &Button, &LeftView);
|
||||
if(DoButton_CheckBox(&g_Config.m_ClShowCheckpointDiff, Localize("Show checkpoint difference"), g_Config.m_ClShowCheckpointDiff, &Button))
|
||||
g_Config.m_ClShowCheckpointDiff ^= 1;
|
||||
|
||||
LeftView.HSplitTop(20.0f, &Button, &LeftView);
|
||||
if(DoButton_CheckBox(&g_Config.m_ClShowRecords, Localize("Show records"), g_Config.m_ClShowRecords, &Button))
|
||||
g_Config.m_ClShowRecords ^= 1;
|
||||
|
||||
if(g_Config.m_ClShowRecords)
|
||||
{
|
||||
LeftView.HSplitTop(20.0f, &Button, &LeftView);
|
||||
Button.VSplitLeft(15.0f, 0, &Button);
|
||||
if(DoButton_CheckBox(&g_Config.m_ClShowServerRecord, Localize("Show best time on server"), g_Config.m_ClShowServerRecord, &Button))
|
||||
g_Config.m_ClShowServerRecord ^= 1;
|
||||
|
||||
LeftView.HSplitTop(20.0f, &Button, &LeftView);
|
||||
Button.VSplitLeft(15.0f, 0, &Button);
|
||||
if(DoButton_CheckBox(&g_Config.m_ClShowLocalRecord, Localize("Show personal best time"), g_Config.m_ClShowLocalRecord, &Button))
|
||||
g_Config.m_ClShowLocalRecord ^= 1;
|
||||
}
|
||||
else
|
||||
LeftView.HSplitTop(40.0f, &Button, &LeftView);
|
||||
|
||||
// Right
|
||||
RightView.HSplitTop(20.0f, &Button, &RightView);
|
||||
UI()->DoLabel(&Button, Localize("Global settings"), 14.0f, -1);
|
||||
|
||||
RightView.HSplitTop(20.0f, &Button, &RightView);
|
||||
if(DoButton_CheckBox(&g_Config.m_ClRenderSpeedmeter, Localize("Show speedmeter"), g_Config.m_ClRenderSpeedmeter, &Button))
|
||||
g_Config.m_ClRenderSpeedmeter ^= 1;
|
||||
|
||||
if(g_Config.m_ClRenderSpeedmeter)
|
||||
{
|
||||
RightView.HSplitTop(20.0f, &Button, &RightView);
|
||||
Button.VSplitLeft(15.0f, 0, &Button);
|
||||
if(DoButton_CheckBox(&g_Config.m_ClSpeedmeterAccel, Localize("Show acceleration"), g_Config.m_ClSpeedmeterAccel, &Button))
|
||||
g_Config.m_ClSpeedmeterAccel ^= 1;
|
||||
}
|
||||
else
|
||||
LeftView.HSplitTop(20.0f, &Button, &LeftView);
|
||||
}
|
||||
|
||||
class CLanguage
|
||||
{
|
||||
public:
|
||||
|
@ -889,9 +748,7 @@ void CMenus::RenderSettings(CUIRect MainView)
|
|||
Localize("Player"),
|
||||
Localize("Controls"),
|
||||
Localize("Graphics"),
|
||||
Localize("Sound"),
|
||||
Localize("Dl.Ext"),
|
||||
Localize("Race")};
|
||||
Localize("Sound")};
|
||||
|
||||
int NumTabs = (int)(sizeof(aTabs)/sizeof(*aTabs));
|
||||
|
||||
|
@ -915,10 +772,6 @@ void CMenus::RenderSettings(CUIRect MainView)
|
|||
RenderSettingsGraphics(MainView);
|
||||
else if(s_SettingsPage == 4)
|
||||
RenderSettingsSound(MainView);
|
||||
else if(s_SettingsPage == 5)
|
||||
RenderSettingsDownloadExtension(MainView);
|
||||
else if(s_SettingsPage == 6)
|
||||
RenderSettingsRace(MainView);
|
||||
|
||||
if(m_NeedRestart)
|
||||
{
|
||||
|
|
|
@ -27,20 +27,15 @@ void CNamePlates::RenderNameplate(
|
|||
a = clamp(1-powf(distance(m_pClient->m_pControls->m_TargetPos, Position)/200.0f,16.0f), 0.0f, 1.0f);
|
||||
|
||||
const char *pName = m_pClient->m_aClients[pPlayerInfo->m_ClientId].m_aName;
|
||||
float FontSize = 28.0f;
|
||||
float tw = TextRender()->TextWidth(0, FontSize, pName, -1);
|
||||
CGameClient::CClientData currentData = m_pClient->m_aClients[pPlayerInfo->m_ClientId];
|
||||
TextRender()->TextColor(
|
||||
(float)(m_PredefinedColors[pPlayerInfo->m_ClientId].r)/255.0f,
|
||||
(float)(m_PredefinedColors[pPlayerInfo->m_ClientId].g)/255.0f,
|
||||
(float)(m_PredefinedColors[pPlayerInfo->m_ClientId].b)/255.0f,a);
|
||||
TextRender()->Text(0, Position.x-tw/2.0f, Position.y-60, FontSize, pName, -1);
|
||||
float tw = TextRender()->TextWidth(0, 28.0f, pName, -1);
|
||||
TextRender()->TextColor(1,1,1,a);
|
||||
TextRender()->Text(0, Position.x-tw/2.0f, Position.y-60, 28.0f, pName, -1);
|
||||
|
||||
if(g_Config.m_Debug) // render client id when in debug aswell
|
||||
{
|
||||
char aBuf[128];
|
||||
str_format(aBuf, sizeof(aBuf),"%d", pPlayerInfo->m_ClientId);
|
||||
TextRender()->Text(0, Position.x, Position.y-90, FontSize, aBuf, -1);
|
||||
TextRender()->Text(0, Position.x, Position.y-90, 28.0f, aBuf, -1);
|
||||
}
|
||||
|
||||
TextRender()->TextColor(1,1,1,1);
|
||||
|
|
|
@ -1,187 +0,0 @@
|
|||
#include <stdio.h>
|
||||
|
||||
#include <engine/shared/config.h>
|
||||
#include <engine/serverbrowser.h>
|
||||
#include <engine/storage.h>
|
||||
|
||||
#include <game/client/components/menus.h>
|
||||
|
||||
#include "race_demo.h"
|
||||
|
||||
CRaceDemo::CRaceDemo()
|
||||
{
|
||||
m_RaceState = RACE_NONE;
|
||||
m_RecordStopTime = 0;
|
||||
m_Time = 0;
|
||||
m_DemoStartTick = 0;
|
||||
}
|
||||
|
||||
void CRaceDemo::OnRender()
|
||||
{
|
||||
if(!g_Config.m_ClAutoRecord || !m_pClient->m_Snap.m_pGameobj || m_pClient->m_Snap.m_Spectate)
|
||||
{
|
||||
m_Active = m_pClient->m_Snap.m_aCharacters[m_pClient->m_Snap.m_LocalCid].m_Active;
|
||||
return;
|
||||
}
|
||||
|
||||
// only for race
|
||||
if(!m_pClient->m_IsRace)
|
||||
return;
|
||||
|
||||
vec2 PlayerPos = m_pClient->m_LocalCharacterPos;
|
||||
|
||||
// start the demo
|
||||
if(((!m_Active && !m_pClient->m_IsFastCap && m_pClient->m_Snap.m_aCharacters[m_pClient->m_Snap.m_LocalCid].m_Active) ||
|
||||
(m_pClient->m_IsFastCap && m_pClient->m_FlagPos != vec2(-1, -1) && distance(PlayerPos, m_pClient->m_FlagPos) < 200)) && m_DemoStartTick < Client()->GameTick())
|
||||
{
|
||||
if(m_RaceState == RACE_STARTED)
|
||||
OnReset();
|
||||
|
||||
m_pMap = Client()->RaceRecordStart("tmp");
|
||||
m_DemoStartTick = Client()->GameTick() + Client()->GameTickSpeed();
|
||||
m_RaceState = RACE_STARTED;
|
||||
}
|
||||
|
||||
// stop the demo
|
||||
if(m_RaceState == RACE_FINISHED && m_RecordStopTime < Client()->GameTick() && m_Time > 0)
|
||||
{
|
||||
CheckDemo();
|
||||
OnReset();
|
||||
}
|
||||
|
||||
m_Active = m_pClient->m_Snap.m_aCharacters[m_pClient->m_Snap.m_LocalCid].m_Active;
|
||||
}
|
||||
|
||||
void CRaceDemo::OnReset()
|
||||
{
|
||||
if(m_RaceState > RACE_NONE)
|
||||
Client()->RaceRecordStop();
|
||||
|
||||
// remove tmp demo
|
||||
if(m_RaceState == RACE_STARTED)
|
||||
{
|
||||
char aBuffer[512];
|
||||
char aFilename[512];
|
||||
str_format(aBuffer, sizeof(aBuffer), "demos/%s_tmp.demo", m_pMap);
|
||||
Storage()->SavePath(aBuffer, aFilename, sizeof(aFilename));
|
||||
remove(aFilename);
|
||||
}
|
||||
|
||||
m_Time = 0;
|
||||
m_RaceState = RACE_NONE;
|
||||
m_RecordStopTime = 0;
|
||||
m_DemoStartTick = 0;
|
||||
}
|
||||
|
||||
void CRaceDemo::OnMessage(int MsgType, void *pRawMsg)
|
||||
{
|
||||
if(!g_Config.m_ClAutoRecord || m_pClient->m_Snap.m_Spectate)
|
||||
return;
|
||||
|
||||
// only for race
|
||||
if(!m_pClient->m_IsRace)
|
||||
return;
|
||||
|
||||
// check for messages from server
|
||||
if(MsgType == NETMSGTYPE_SV_KILLMSG)
|
||||
{
|
||||
CNetMsg_Sv_KillMsg *pMsg = (CNetMsg_Sv_KillMsg *)pRawMsg;
|
||||
if(pMsg->m_Victim == m_pClient->m_Snap.m_LocalCid && m_RaceState == RACE_FINISHED)
|
||||
{
|
||||
// check for new record
|
||||
CheckDemo();
|
||||
OnReset();
|
||||
}
|
||||
}
|
||||
else if(MsgType == NETMSGTYPE_SV_CHAT)
|
||||
{
|
||||
CNetMsg_Sv_Chat *pMsg = (CNetMsg_Sv_Chat *)pRawMsg;
|
||||
if(pMsg->m_Cid == -1 && m_RaceState == RACE_STARTED)
|
||||
{
|
||||
const char* pMessage = pMsg->m_pMessage;
|
||||
|
||||
int Num = 0;
|
||||
while(str_comp_num(pMessage, " finished in: ", 14))
|
||||
{
|
||||
pMessage++;
|
||||
Num++;
|
||||
if(!pMessage[0])
|
||||
return;
|
||||
}
|
||||
|
||||
// store the name
|
||||
char aName[64];
|
||||
str_copy(aName, pMsg->m_pMessage, Num+1);
|
||||
|
||||
// prepare values and state for saving
|
||||
int Minutes;
|
||||
float Seconds;
|
||||
if(!str_comp(aName, m_pClient->m_aClients[m_pClient->m_Snap.m_LocalCid].m_aName) && sscanf(pMessage, " finished in: %d minute(s) %f", &Minutes, &Seconds) == 2)
|
||||
{
|
||||
m_RaceState = RACE_FINISHED;
|
||||
m_RecordStopTime = Client()->GameTick() + Client()->GameTickSpeed();
|
||||
m_Time = Minutes*60 + Seconds;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CRaceDemo::CheckDemo()
|
||||
{
|
||||
// stop the demo recording
|
||||
Client()->RaceRecordStop();
|
||||
|
||||
char aDemoName[128];
|
||||
str_format(aDemoName, sizeof(aDemoName), "%s_best_", m_pMap);
|
||||
|
||||
// loop through demo files
|
||||
m_pClient->m_pMenus->DemolistPopulate();
|
||||
for(int i = 0; i < m_pClient->m_pMenus->m_lDemos.size(); i++)
|
||||
{
|
||||
if(!str_comp_num(m_pClient->m_pMenus->m_lDemos[i].m_aName, aDemoName, str_length(aDemoName)))
|
||||
{
|
||||
const char *pDemo = m_pClient->m_pMenus->m_lDemos[i].m_aName;
|
||||
|
||||
// set cursor
|
||||
while(str_comp_num(pDemo, "best_", 5))
|
||||
{
|
||||
pDemo++;
|
||||
if(!pDemo[0])
|
||||
return;
|
||||
}
|
||||
|
||||
float DemoTime;
|
||||
sscanf(pDemo, "best_%f", &DemoTime);
|
||||
if(m_Time < DemoTime)
|
||||
{
|
||||
// save new record
|
||||
SaveDemo(aDemoName);
|
||||
|
||||
// delete old demo
|
||||
remove(m_pClient->m_pMenus->m_lDemos[i].m_aFilename);
|
||||
}
|
||||
|
||||
m_Time = 0;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// save demo if there is none
|
||||
SaveDemo(aDemoName);
|
||||
|
||||
m_Time = 0;
|
||||
}
|
||||
|
||||
void CRaceDemo::SaveDemo(const char* pDemo)
|
||||
{
|
||||
char aFilename[512];
|
||||
char aOldFilename[512];
|
||||
char aBuffer[512];
|
||||
str_format(aBuffer, sizeof(aBuffer), "demos/%s%5.2f.demo", pDemo, m_Time);
|
||||
Storage()->SavePath(aBuffer, aFilename, sizeof(aFilename));
|
||||
str_format(aBuffer, sizeof(aBuffer), "demos/%s_tmp.demo", m_pMap);
|
||||
Storage()->SavePath(aBuffer, aOldFilename, sizeof(aOldFilename));
|
||||
|
||||
rename(aOldFilename, aFilename);
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
#ifndef GAME_CLIENT_COMPONENTS_RACE_DEMO_H
|
||||
#define GAME_CLIENT_COMPONENTS_RACE_DEMO_H
|
||||
|
||||
#include <game/client/gameclient.h>
|
||||
|
||||
#include <game/client/component.h>
|
||||
|
||||
class CRaceDemo : public CComponent
|
||||
{
|
||||
int m_RecordStopTime;
|
||||
int m_DemoStartTick;
|
||||
const char *m_pMap;
|
||||
|
||||
bool m_Active;
|
||||
|
||||
public:
|
||||
|
||||
float m_Time;
|
||||
int m_RaceState;
|
||||
|
||||
enum
|
||||
{
|
||||
RACE_NONE = 0,
|
||||
RACE_STARTED,
|
||||
RACE_FINISHED,
|
||||
};
|
||||
|
||||
CRaceDemo();
|
||||
|
||||
virtual void OnReset();
|
||||
virtual void OnRender();
|
||||
virtual void OnMessage(int MsgType, void *pRawMsg);
|
||||
|
||||
float GetFinishTime() { return m_Time; }
|
||||
int GetRaceState() { return m_RaceState; }
|
||||
void CheckDemo();
|
||||
void SaveDemo(const char* pDemo);
|
||||
};
|
||||
#endif
|
|
@ -120,7 +120,7 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch
|
|||
{
|
||||
//float ystart = y;
|
||||
float h = 750.0f;
|
||||
|
||||
|
||||
Graphics()->BlendNormal();
|
||||
Graphics()->TextureSet(-1);
|
||||
Graphics()->QuadsBegin();
|
||||
|
@ -136,15 +136,7 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch
|
|||
else
|
||||
pTitle = Localize("Score board");
|
||||
}
|
||||
|
||||
float Offset = 0;
|
||||
float DataOffset = 0;
|
||||
if(m_pClient->m_IsRace)
|
||||
{
|
||||
Offset = 80.0f;
|
||||
DataOffset = 130;
|
||||
}
|
||||
|
||||
|
||||
float tw = TextRender()->TextWidth(0, 48, pTitle, -1);
|
||||
|
||||
if(Team == -1)
|
||||
|
@ -159,12 +151,9 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch
|
|||
{
|
||||
char aBuf[128];
|
||||
int Score = Team ? m_pClient->m_Snap.m_pGameobj->m_TeamscoreBlue : m_pClient->m_Snap.m_pGameobj->m_TeamscoreRed;
|
||||
if(!m_pClient->m_IsRace)
|
||||
{
|
||||
str_format(aBuf, sizeof(aBuf), "%d", Score);
|
||||
tw = TextRender()->TextWidth(0, 48, aBuf, -1);
|
||||
TextRender()->Text(0, x+w-tw-30, y, 48, aBuf, -1);
|
||||
}
|
||||
str_format(aBuf, sizeof(aBuf), "%d", Score);
|
||||
tw = TextRender()->TextWidth(0, 48, aBuf, -1);
|
||||
TextRender()->Text(0, x+w-tw-30, y, 48, aBuf, -1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -195,38 +184,26 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch
|
|||
{
|
||||
for(int i = 0; i < NumPlayers-k-1; i++)
|
||||
{
|
||||
if(m_pClient->m_IsRace)
|
||||
if(paPlayers[i]->m_Score < paPlayers[i+1]->m_Score)
|
||||
{
|
||||
if(m_pClient->m_aClients[paPlayers[i]->m_ClientId].m_Score == 0 || (m_pClient->m_aClients[paPlayers[i]->m_ClientId].m_Score > m_pClient->m_aClients[paPlayers[i+1]->m_ClientId].m_Score && m_pClient->m_aClients[paPlayers[i+1]->m_ClientId].m_Score != 0))
|
||||
{
|
||||
const CNetObj_PlayerInfo *pTmp = paPlayers[i];
|
||||
paPlayers[i] = paPlayers[i+1];
|
||||
paPlayers[i+1] = pTmp;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(paPlayers[i]->m_Score < paPlayers[i+1]->m_Score)
|
||||
{
|
||||
const CNetObj_PlayerInfo *pTmp = paPlayers[i];
|
||||
paPlayers[i] = paPlayers[i+1];
|
||||
paPlayers[i+1] = pTmp;
|
||||
}
|
||||
const CNetObj_PlayerInfo *pTmp = paPlayers[i];
|
||||
paPlayers[i] = paPlayers[i+1];
|
||||
paPlayers[i+1] = pTmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// render headlines
|
||||
TextRender()->Text(0, x+10, y, 24.0f, Localize("Score"), -1);
|
||||
TextRender()->Text(0, x+125+Offset, y, 24.0f, Localize("Name"), -1);
|
||||
TextRender()->Text(0, x+w-75, y, 24.0f, Localize("Ping"), -1);
|
||||
TextRender()->Text(0, x+125, y, 24.0f, Localize("Name"), -1);
|
||||
TextRender()->Text(0, x+w-70, y, 24.0f, Localize("Ping"), -1);
|
||||
y += 29.0f;
|
||||
|
||||
float FontSize = 35.0f;
|
||||
float LineHeight = 50.0f;
|
||||
float TeeSizeMod = 1.0f;
|
||||
float TeeOffset = 0.0f;
|
||||
|
||||
|
||||
if(NumPlayers > 13)
|
||||
{
|
||||
FontSize = 30.0f;
|
||||
|
@ -253,42 +230,25 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch
|
|||
Graphics()->QuadsEnd();
|
||||
}
|
||||
|
||||
if(m_pClient->m_IsRace)
|
||||
{
|
||||
float Time = m_pClient->m_aClients[pInfo->m_ClientId].m_Score;
|
||||
if(Time > 0)
|
||||
{
|
||||
str_format(aBuf, sizeof(aBuf), "%02d:%05.2f", (int)Time/60, Time-((int)Time/60*60));
|
||||
TextRender()->Text(0, x+DataOffset+60-TextRender()->TextWidth(0, FontSize,aBuf,-1), y, FontSize, aBuf, -1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
str_format(aBuf, sizeof(aBuf), "%4d", pInfo->m_Score);
|
||||
TextRender()->Text(0, x+60-TextRender()->TextWidth(0, FontSize,aBuf,-1), y, FontSize, aBuf, -1);
|
||||
}
|
||||
float FontSizeResize = FontSize;
|
||||
float Width;
|
||||
const float ScoreWidth = 60.0f;
|
||||
const float PingWidth = 60.0f;
|
||||
str_format(aBuf, sizeof(aBuf), "%d", clamp(pInfo->m_Score, -9999, 9999));
|
||||
while((Width = TextRender()->TextWidth(0, FontSizeResize, aBuf, -1)) > ScoreWidth)
|
||||
--FontSizeResize;
|
||||
TextRender()->Text(0, x+ScoreWidth-Width, y+(FontSize-FontSizeResize)/2, FontSizeResize, aBuf, -1);
|
||||
|
||||
float FontSizeName = FontSize;
|
||||
while(TextRender()->TextWidth(0, FontSizeName, m_pClient->m_aClients[pInfo->m_ClientId].m_aName, -1) > w-200)
|
||||
--FontSizeName;
|
||||
CGameClient::CClientData currentData = m_pClient->m_aClients[pInfo->m_ClientId];
|
||||
TextRender()->TextColor(
|
||||
(float)(m_PredefinedColors[pInfo->m_ClientId].r)/255.0f,
|
||||
(float)(m_PredefinedColors[pInfo->m_ClientId].g)/255.0f,
|
||||
(float)(m_PredefinedColors[pInfo->m_ClientId].b)/255.0f, 1);
|
||||
if(m_pClient->m_IsRace)
|
||||
{
|
||||
CTextCursor Cursor;
|
||||
TextRender()->SetCursor(&Cursor, x+128+DataOffset, y+(FontSize-FontSizeName)/2, FontSizeName, TEXTFLAG_RENDER|TEXTFLAG_STOP_AT_END);
|
||||
Cursor.m_LineWidth = 400;
|
||||
TextRender()->TextEx(&Cursor, m_pClient->m_aClients[pInfo->m_ClientId].m_aName, -1);
|
||||
}
|
||||
else
|
||||
TextRender()->Text(0, x+128+DataOffset, y+(FontSize-FontSizeName)/2, FontSizeName, m_pClient->m_aClients[pInfo->m_ClientId].m_aName, -1);
|
||||
|
||||
str_format(aBuf, sizeof(aBuf), "%4d", pInfo->m_Latency);
|
||||
float tw = TextRender()->TextWidth(0, FontSize, aBuf, -1);
|
||||
TextRender()->Text(0, x+w-tw-35, y, FontSize, aBuf, -1);
|
||||
FontSizeResize = FontSize;
|
||||
while(TextRender()->TextWidth(0, FontSizeResize, m_pClient->m_aClients[pInfo->m_ClientId].m_aName, -1) > w-163.0f-PingWidth)
|
||||
--FontSizeResize;
|
||||
TextRender()->Text(0, x+128.0f, y+(FontSize-FontSizeResize)/2, FontSizeResize, m_pClient->m_aClients[pInfo->m_ClientId].m_aName, -1);
|
||||
|
||||
FontSizeResize = FontSize;
|
||||
str_format(aBuf, sizeof(aBuf), "%d", clamp(pInfo->m_Latency, -9999, 9999));
|
||||
while((Width = TextRender()->TextWidth(0, FontSizeResize, aBuf, -1)) > PingWidth)
|
||||
--FontSizeResize;
|
||||
TextRender()->Text(0, x+w-35.0f-Width, y+(FontSize-FontSizeResize)/2, FontSizeResize, aBuf, -1);
|
||||
|
||||
// render avatar
|
||||
if((m_pClient->m_Snap.m_paFlags[0] && m_pClient->m_Snap.m_paFlags[0]->m_CarriedBy == pInfo->m_ClientId) ||
|
||||
|
@ -302,14 +262,14 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch
|
|||
else RenderTools()->SelectSprite(SPRITE_FLAG_RED, SPRITE_FLAG_FLIP_X);
|
||||
|
||||
float size = 64.0f;
|
||||
IGraphics::CQuadItem QuadItem(x+55+DataOffset, y-15, size/2, size);
|
||||
IGraphics::CQuadItem QuadItem(x+55, y-15, size/2, size);
|
||||
Graphics()->QuadsDrawTL(&QuadItem, 1);
|
||||
Graphics()->QuadsEnd();
|
||||
}
|
||||
|
||||
CTeeRenderInfo TeeInfo = m_pClient->m_aClients[pInfo->m_ClientId].m_RenderInfo;
|
||||
TeeInfo.m_Size *= TeeSizeMod;
|
||||
RenderTools()->RenderTee(CAnimState::GetIdle(), &TeeInfo, EMOTE_NORMAL, vec2(1,0), vec2(x+90+DataOffset, y+28+TeeOffset));
|
||||
RenderTools()->RenderTee(CAnimState::GetIdle(), &TeeInfo, EMOTE_NORMAL, vec2(1,0), vec2(x+90, y+28+TeeOffset));
|
||||
|
||||
|
||||
y += LineHeight;
|
||||
|
@ -372,11 +332,7 @@ void CScoreboard::OnRender()
|
|||
Graphics()->MapScreen(0, 0, Width, Height);
|
||||
|
||||
float w = 650.0f;
|
||||
|
||||
// resize scoreboard for race
|
||||
if(m_pClient->m_IsRace)
|
||||
w = 750.0f;
|
||||
|
||||
|
||||
if(m_pClient->m_Snap.m_pGameobj && !(m_pClient->m_Snap.m_pGameobj->m_Flags&GAMEFLAG_TEAMS))
|
||||
{
|
||||
RenderScoreboard(Width/2-w/2, 150.0f, w, 0, 0);
|
||||
|
|
|
@ -42,7 +42,6 @@
|
|||
#include "components/skins.h"
|
||||
#include "components/sounds.h"
|
||||
#include "components/voting.h"
|
||||
#include "components/race_demo.h"
|
||||
|
||||
CGameClient g_GameClient;
|
||||
|
||||
|
@ -67,7 +66,6 @@ static CSounds gs_Sounds;
|
|||
static CEmoticon gs_Emoticon;
|
||||
static CDamageInd gsDamageInd;
|
||||
static CVoting gs_Voting;
|
||||
static CRaceDemo gs_RaceDemo;
|
||||
|
||||
static CPlayers gs_Players;
|
||||
static CNamePlates gs_NamePlates;
|
||||
|
@ -101,14 +99,11 @@ static int gs_LoadTotal;
|
|||
}
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
static void ConServerDummy(IConsole::IResult *pResult, void *pUserData, int ClientID)
|
||||
{
|
||||
dbg_msg("client", "this command is not available on the client");
|
||||
}
|
||||
|
||||
|
||||
#include <base/tl/sorted_array.h>
|
||||
|
||||
const char *CGameClient::Version() { return GAME_VERSION; }
|
||||
|
@ -144,7 +139,6 @@ void CGameClient::OnConsoleInit()
|
|||
m_pDamageind = &::gsDamageInd;
|
||||
m_pMapimages = &::gs_MapImages;
|
||||
m_pVoting = &::gs_Voting;
|
||||
m_pRaceDemo = &::gs_RaceDemo;
|
||||
m_pScoreboard = &::gs_Scoreboard;
|
||||
|
||||
// make a list of all the systems, make sure to add them in the corrent render order
|
||||
|
@ -158,7 +152,6 @@ void CGameClient::OnConsoleInit()
|
|||
m_All.Add(m_pSounds);
|
||||
m_All.Add(m_pVoting);
|
||||
m_All.Add(m_pParticles); // doesn't render anything, just updates all the particles
|
||||
m_All.Add(m_pRaceDemo);
|
||||
|
||||
m_All.Add(&gs_MapLayersBackGround); // first to render
|
||||
m_All.Add(&m_pParticles->m_RenderTrail);
|
||||
|
@ -196,30 +189,16 @@ void CGameClient::OnConsoleInit()
|
|||
Console()->Register("kill", "", CFGFLAG_CLIENT, ConKill, this, "Kill yourself", 0);
|
||||
|
||||
// register server dummy commands for tab completion
|
||||
|
||||
Console()->Register("tune", "si", CFGFLAG_SERVER, ConServerDummy, 0, "Tune variable to value", 0);
|
||||
Console()->Register("tune_reset", "", CFGFLAG_SERVER, ConServerDummy, 0, "Reset tuning", 0);
|
||||
Console()->Register("tune_dump", "", CFGFLAG_SERVER, ConServerDummy, 0, "Dump tuning", 0);
|
||||
Console()->Register("change_map", "r", CFGFLAG_SERVER, ConServerDummy, 0, "Change map", 0);
|
||||
Console()->Register("restart", "?i", CFGFLAG_SERVER, ConServerDummy, 0, "Restart in x seconds", 0);
|
||||
Console()->Register("broadcast", "r", CFGFLAG_SERVER, ConServerDummy, 0, "Broadcast message", 0);
|
||||
//MACRO_REGISTER_COMMAND("say", "r", CFGFLAG_SERVER, con_serverdummy, 0);
|
||||
Console()->Register("say", "r", CFGFLAG_SERVER, ConServerDummy, 0, "Say in chat", 0);
|
||||
Console()->Register("set_team", "ii", CFGFLAG_SERVER, ConServerDummy, 0, "Set team of player to team", 0);
|
||||
Console()->Register("addvote", "r", CFGFLAG_SERVER, ConServerDummy, 0, "Add a voting option", 0);
|
||||
//MACRO_REGISTER_COMMAND("vote", "", CFGFLAG_SERVER, con_serverdummy, 0);
|
||||
Console()->Register("map_hack", "", CFGFLAG_CLIENT, ConMapHack, 0, "Tune variable to value", 0);
|
||||
|
||||
Console()->Register("tune", "si", CFGFLAG_SERVER, 0, 0, "Tune variable to value", 0);
|
||||
Console()->Register("tune_reset", "", CFGFLAG_SERVER, 0, 0, "Reset tuning", 0);
|
||||
Console()->Register("tune_dump", "", CFGFLAG_SERVER, 0, 0, "Dump tuning", 0);
|
||||
Console()->Register("change_map", "r", CFGFLAG_SERVER, 0, 0, "Change map", 0);
|
||||
Console()->Register("restart", "?i", CFGFLAG_SERVER, 0, 0, "Restart in x seconds", 0);
|
||||
Console()->Register("broadcast", "r", CFGFLAG_SERVER, 0, 0, "Broadcast message", 0);
|
||||
Console()->Register("say", "r", CFGFLAG_SERVER, 0, 0, "Say in chat", 0);
|
||||
Console()->Register("set_team", "ii", CFGFLAG_SERVER, 0, 0, "Set team of player to team", 0);
|
||||
Console()->Register("addvote", "r", CFGFLAG_SERVER, 0, 0, "Add a voting option", 0);
|
||||
Console()->Register("vote", "r", CFGFLAG_SERVER, 0, 0, "Force a vote to yes/no", 0);
|
||||
|
||||
Console()->Register("vote", "r", CFGFLAG_SERVER, ConServerDummy, 0, "Force a vote to yes/no", 0);
|
||||
|
||||
|
||||
// propagate pointers
|
||||
|
@ -320,11 +299,6 @@ void CGameClient::OnInit()
|
|||
Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "gameclient", aBuf);
|
||||
|
||||
m_ServerMode = SERVERMODE_PURE;
|
||||
|
||||
m_IsRace = false;
|
||||
m_RaceMsgSent = false;
|
||||
m_ShowOthers = -1;
|
||||
m_FlagPos = vec2(-1, -1);
|
||||
}
|
||||
|
||||
void CGameClient::DispatchInput()
|
||||
|
@ -406,19 +380,11 @@ void CGameClient::OnReset()
|
|||
m_aClients[i].m_SkinInfo.m_Texture = g_GameClient.m_pSkins->Get(0)->m_ColorTexture;
|
||||
m_aClients[i].m_SkinInfo.m_ColorBody = vec4(1,1,1,1);
|
||||
m_aClients[i].m_SkinInfo.m_ColorFeet = vec4(1,1,1,1);
|
||||
m_aClients[i].m_Score = 0;
|
||||
m_aClients[i].UpdateRenderInfo();
|
||||
}
|
||||
|
||||
for(int i = 0; i < m_All.m_Num; i++)
|
||||
m_All.m_paComponents[i]->OnReset();
|
||||
|
||||
// Race
|
||||
m_IsRace = false;
|
||||
m_RaceMsgSent = false;
|
||||
m_ShowOthers = -1;
|
||||
m_FlagPos = vec2(-1, -1);
|
||||
m_Teams.Reset();
|
||||
}
|
||||
|
||||
|
||||
|
@ -446,9 +412,8 @@ static void Evolve(CNetObj_Character *pCharacter, int Tick)
|
|||
{
|
||||
CWorldCore TempWorld;
|
||||
CCharacterCore TempCore;
|
||||
CTeamsCore TempTeams;
|
||||
mem_zero(&TempCore, sizeof(TempCore));
|
||||
TempCore.Init(&TempWorld, g_GameClient.Collision(), &TempTeams);//????
|
||||
TempCore.Init(&TempWorld, g_GameClient.Collision());
|
||||
TempCore.Read(pCharacter);
|
||||
|
||||
while(pCharacter->m_Tick < Tick)
|
||||
|
@ -602,22 +567,7 @@ void CGameClient::OnMessage(int MsgId, CUnpacker *pUnpacker)
|
|||
g_GameClient.m_pSounds->Enqueue(pMsg->m_Soundid);
|
||||
else
|
||||
g_GameClient.m_pSounds->Play(CSounds::CHN_GLOBAL, pMsg->m_Soundid, 1.0f, vec2(0,0));
|
||||
}
|
||||
else if(MsgId == NETMSGTYPE_SV_PLAYERTIME)
|
||||
{
|
||||
CNetMsg_Sv_PlayerTime *pMsg = (CNetMsg_Sv_PlayerTime *)pRawMsg;
|
||||
m_aClients[pMsg->m_Cid].m_Score = (float)pMsg->m_Time/100;
|
||||
//m_pClient->m_LocalTime = (float)pMsg->m_Time/100;
|
||||
m_pRaceDemo->m_Time = (float)pMsg->m_Time/100;
|
||||
}
|
||||
else if(MsgId == NETMSGTYPE_SV_PLAYERTEAM)
|
||||
{
|
||||
CNetMsg_Sv_PlayerTeam *pMsg = (CNetMsg_Sv_PlayerTeam *)pRawMsg;
|
||||
m_Teams.Team(pMsg->m_Cid, pMsg->m_Team);
|
||||
char aBuf[512];
|
||||
str_format(aBuf, sizeof(aBuf), "Id = %d Team = %d",pMsg->m_Cid, pMsg->m_Team);
|
||||
dbg_msg("Teams", aBuf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CGameClient::OnStateChange(int NewState, int OldState)
|
||||
|
@ -692,9 +642,6 @@ void CGameClient::OnNewSnapshot()
|
|||
mem_zero(&g_GameClient.m_Snap, sizeof(g_GameClient.m_Snap));
|
||||
m_Snap.m_LocalCid = -1;
|
||||
|
||||
// mark all clients offline here
|
||||
bool Online[MAX_CLIENTS] = { 0 };
|
||||
|
||||
// secure snapshot
|
||||
{
|
||||
int Num = Client()->SnapNumItems(IClient::SNAP_CURRENT);
|
||||
|
@ -784,8 +731,6 @@ void CGameClient::OnNewSnapshot()
|
|||
m_aClients[Cid].UpdateRenderInfo();
|
||||
g_GameClient.m_Snap.m_NumPlayers++;
|
||||
|
||||
// mark Player as online
|
||||
Online[Cid] = true;
|
||||
}
|
||||
else if(Item.m_Type == NETOBJTYPE_PLAYERINFO)
|
||||
{
|
||||
|
@ -850,8 +795,6 @@ void CGameClient::OnNewSnapshot()
|
|||
m_Snap.m_Spectate = true;
|
||||
|
||||
CTuningParams StandardTuning;
|
||||
StandardTuning.m_PlayerCollision = 1;
|
||||
StandardTuning.m_PlayerHooking = 1;
|
||||
CServerInfo CurrentServerInfo;
|
||||
Client()->GetServerInfo(&CurrentServerInfo);
|
||||
if(CurrentServerInfo.m_aGameType[0] != '0')
|
||||
|
@ -863,72 +806,7 @@ void CGameClient::OnNewSnapshot()
|
|||
else
|
||||
m_ServerMode = SERVERMODE_PUREMOD;
|
||||
}
|
||||
// send race msg
|
||||
if(m_Snap.m_pLocalInfo)
|
||||
{
|
||||
CServerInfo CurrentServerInfo;
|
||||
Client()->GetServerInfo(&CurrentServerInfo);
|
||||
if(str_find_nocase(CurrentServerInfo.m_aGameType, "race") || str_find_nocase(CurrentServerInfo.m_aGameType, "fastcap") || str_find_nocase(CurrentServerInfo.m_aGameType, "ddrace"))
|
||||
{
|
||||
if(!m_IsRace)
|
||||
m_IsRace = true;
|
||||
if(str_find_nocase(CurrentServerInfo.m_aGameType, "fastcap"))
|
||||
{
|
||||
m_IsFastCap = true;
|
||||
|
||||
// get Flag Pos (for demo recording)
|
||||
m_FlagPos = vec2(-1, -1);
|
||||
int Num = Client()->SnapNumItems(IClient::SNAP_CURRENT);
|
||||
for(int i = 0; i < Num; i++)
|
||||
{
|
||||
IClient::CSnapItem Item;
|
||||
const void *pData = Client()->SnapGetItem(IClient::SNAP_CURRENT, i, &Item);
|
||||
|
||||
if(Item.m_Type == NETOBJTYPE_FLAG)
|
||||
{
|
||||
const CNetObj_Flag *pFlag = (const CNetObj_Flag *)pData;
|
||||
if(pFlag->m_CarriedBy == -2 && pFlag->m_Team != m_aClients[m_Snap.m_LocalCid].m_Team)
|
||||
m_FlagPos = vec2(pFlag->m_X, pFlag->m_Y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!m_RaceMsgSent && m_Snap.m_pLocalInfo)
|
||||
{
|
||||
CNetMsg_Cl_IsRace Msg;
|
||||
Client()->SendPackMsg(&Msg, MSGFLAG_VITAL);
|
||||
m_RaceMsgSent = true;
|
||||
}
|
||||
|
||||
if(m_ShowOthers == -1 || (m_ShowOthers > -1 && m_ShowOthers != g_Config.m_ClShowOthers))
|
||||
{
|
||||
if(m_ShowOthers == -1 && g_Config.m_ClShowOthers)
|
||||
m_ShowOthers = 1;
|
||||
else
|
||||
{
|
||||
CNetMsg_Cl_RaceShowOthers Msg;
|
||||
Msg.m_Active = g_Config.m_ClShowOthers;
|
||||
Client()->SendPackMsg(&Msg, MSGFLAG_VITAL);
|
||||
|
||||
m_ShowOthers = g_Config.m_ClShowOthers;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// reset all scores of offline players
|
||||
if(m_IsRace)
|
||||
{
|
||||
for(int i = 0; i < MAX_CLIENTS; i++)
|
||||
{
|
||||
if(!Online[i])
|
||||
m_aClients[i].m_Score = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// update render info
|
||||
for(int i = 0; i < MAX_CLIENTS; i++)
|
||||
m_aClients[i].UpdateRenderInfo();
|
||||
}
|
||||
|
||||
void CGameClient::OnPredict()
|
||||
|
@ -961,9 +839,8 @@ void CGameClient::OnPredict()
|
|||
if(!m_Snap.m_aCharacters[i].m_Active)
|
||||
continue;
|
||||
|
||||
g_GameClient.m_aClients[i].m_Predicted.Init(&World, Collision(), &m_Teams);
|
||||
g_GameClient.m_aClients[i].m_Predicted.Init(&World, Collision());
|
||||
World.m_apCharacters[i] = &g_GameClient.m_aClients[i].m_Predicted;
|
||||
World.m_apCharacters[i]->m_Id = m_Snap.m_LocalCid;
|
||||
g_GameClient.m_aClients[i].m_Predicted.Read(&m_Snap.m_aCharacters[i].m_Cur);
|
||||
}
|
||||
|
||||
|
@ -1126,10 +1003,6 @@ void CGameClient::ConKill(IConsole::IResult *pResult, void *pUserData, int Clien
|
|||
((CGameClient*)pUserData)->SendKill(-1);
|
||||
}
|
||||
|
||||
void CGameClient::ConMapHack(IConsole::IResult *pResult, void *pUserData, int ClientID) {
|
||||
g_Config.m_GfxClearFull ^= 1;
|
||||
}
|
||||
|
||||
void CGameClient::ConchainSpecialInfoupdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData)
|
||||
{
|
||||
pfnCallback(pResult, pCallbackUserData, -1);
|
||||
|
|
|
@ -6,29 +6,8 @@
|
|||
#include <engine/console.h>
|
||||
#include <game/layers.h>
|
||||
#include <game/gamecore.h>
|
||||
#include <game/teamscore.h>
|
||||
|
||||
#include "render.h"
|
||||
|
||||
const CColor m_PredefinedColors[MAX_CLIENTS] = {
|
||||
{255,255,204, 1},
|
||||
{255,204,204, 1},
|
||||
{204,153,255, 1},
|
||||
{102,153,255, 1},
|
||||
{204, 255, 255, 1},
|
||||
{102,255,0, 1},
|
||||
{204, 255, 51, 1},
|
||||
{204,255,102, 1},
|
||||
{102, 255, 255, 1},
|
||||
{102,255,153, 1},
|
||||
{255, 102, 153, 1},
|
||||
{255, 153, 102, 1},
|
||||
{255, 204, 51, 1},
|
||||
{204,255,51, 1},
|
||||
{255, 255, 255, 1},
|
||||
{204,204,255, 1}
|
||||
};
|
||||
|
||||
class CGameClient : public IGameClient
|
||||
{
|
||||
class CStack
|
||||
|
@ -63,7 +42,6 @@ class CGameClient : public IGameClient
|
|||
|
||||
CLayers m_Layers;
|
||||
class CCollision m_Collision;
|
||||
class CTeamsCore m_Teams;
|
||||
CUI m_UI;
|
||||
|
||||
void DispatchInput();
|
||||
|
@ -77,7 +55,6 @@ class CGameClient : public IGameClient
|
|||
|
||||
static void ConTeam(IConsole::IResult *pResult, void *pUserData, int ClientID);
|
||||
static void ConKill(IConsole::IResult *pResult, void *pUserData, int ClientID);
|
||||
static void ConMapHack(IConsole::IResult *pResult, void *pUserData, int ClientID);
|
||||
|
||||
static void ConchainSpecialInfoupdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData);
|
||||
|
||||
|
@ -104,13 +81,6 @@ public:
|
|||
bool m_SuppressEvents;
|
||||
bool m_NewTick;
|
||||
bool m_NewPredictedTick;
|
||||
|
||||
// Race
|
||||
bool m_IsRace;
|
||||
bool m_IsFastCap;
|
||||
bool m_RaceMsgSent;
|
||||
int m_ShowOthers;
|
||||
vec2 m_FlagPos;
|
||||
|
||||
// TODO: move this
|
||||
CTuningParams m_Tuning;
|
||||
|
@ -185,12 +155,9 @@ public:
|
|||
|
||||
float m_Angle;
|
||||
|
||||
// race
|
||||
float m_Score;
|
||||
|
||||
void UpdateRenderInfo();
|
||||
};
|
||||
|
||||
|
||||
CClientData m_aClients[MAX_CLIENTS];
|
||||
|
||||
CRenderTools m_RenderTools;
|
||||
|
@ -239,10 +206,9 @@ public:
|
|||
class CMotd *m_pMotd;
|
||||
class CMapImages *m_pMapimages;
|
||||
class CVoting *m_pVoting;
|
||||
class CRaceDemo *m_pRaceDemo;
|
||||
class CScoreboard *m_pScoreboard;
|
||||
};
|
||||
|
||||
extern const char *Localize(const char *Str);
|
||||
|
||||
#endif
|
||||
#endif
|
|
@ -70,10 +70,6 @@ public:
|
|||
static void RenderEvalEnvelope(CEnvPoint *pPoints, int NumPoints, int Channels, float Time, float *pResult);
|
||||
void RenderQuads(CQuad *pQuads, int NumQuads, int Flags, void (*pfnEval)(float TimeOffset, int Env, float *pChannels, void *pUser), void *pUser);
|
||||
void RenderTilemap(CTile *pTiles, int w, int h, float Scale, vec4 Color, int Flags);
|
||||
void RenderTelemap(CTeleTile *pTele, int w, int h, float Scale);
|
||||
void RenderSpeedupmap(CSpeedupTile *pTele, int w, int h, float Scale);
|
||||
void RenderFrontmap(CTile *pTiles, int w, int h, float Scale, vec4 Color, int Flags);
|
||||
void RenderSwitchmap(CTeleTile *pSwitch, int w, int h, float Scale);
|
||||
|
||||
// helpers
|
||||
void MapscreenToWorld(float CenterX, float CenterY, float ParallaxX, float ParallaxY,
|
||||
|
|
|
@ -2,10 +2,6 @@
|
|||
#include <math.h>
|
||||
#include <base/math.h>
|
||||
#include <engine/graphics.h>
|
||||
#include <engine/textrender.h>
|
||||
#include <engine/shared/config.h>
|
||||
#include <game/generated/protocol.h>
|
||||
#include <game/generated/client_data.h>
|
||||
|
||||
#include "render.h"
|
||||
|
||||
|
@ -83,8 +79,6 @@ static void Rotate(CPoint *pCenter, CPoint *pPoint, float Rotation)
|
|||
|
||||
void CRenderTools::RenderQuads(CQuad *pQuads, int NumQuads, int RenderFlags, void (*pfnEval)(float TimeOffset, int Env, float *pChannels, void *pUser), void *pUser)
|
||||
{
|
||||
if(g_Config.m_GfxClearFull)
|
||||
return;
|
||||
Graphics()->QuadsBegin();
|
||||
float Conv = 1/255.0f;
|
||||
for(int i = 0; i < NumQuads; i++)
|
||||
|
@ -300,139 +294,3 @@ void CRenderTools::RenderTilemap(CTile *pTiles, int w, int h, float Scale, vec4
|
|||
Graphics()->QuadsEnd();
|
||||
Graphics()->MapScreen(ScreenX0, ScreenY0, ScreenX1, ScreenY1);
|
||||
}
|
||||
|
||||
void CRenderTools::RenderTelemap(CTeleTile *pTele, int w, int h, float Scale)
|
||||
{
|
||||
float ScreenX0, ScreenY0, ScreenX1, ScreenY1;
|
||||
Graphics()->GetScreen(&ScreenX0, &ScreenY0, &ScreenX1, &ScreenY1);
|
||||
|
||||
int StartY = (int)(ScreenY0/Scale)-1;
|
||||
int StartX = (int)(ScreenX0/Scale)-1;
|
||||
int EndY = (int)(ScreenY1/Scale)+1;
|
||||
int EndX = (int)(ScreenX1/Scale)+1;
|
||||
|
||||
for(int y = StartY; y < EndY; y++)
|
||||
for(int x = StartX; x < EndX; x++)
|
||||
{
|
||||
int mx = x;
|
||||
int my = y;
|
||||
|
||||
|
||||
if(mx<0)
|
||||
continue; // mx = 0;
|
||||
if(mx>=w)
|
||||
continue; // mx = w-1;
|
||||
if(my<0)
|
||||
continue; // my = 0;
|
||||
if(my>=h)
|
||||
continue; // my = h-1;
|
||||
|
||||
int c = mx + my*w;
|
||||
|
||||
unsigned char Index = pTele[c].m_Number;
|
||||
if(Index)
|
||||
{
|
||||
char aBuf[16];
|
||||
str_format(aBuf, sizeof(aBuf), "%d", Index);
|
||||
UI()->TextRender()->Text(0, mx*Scale-2, my*Scale-4, Scale-5, aBuf, -1);
|
||||
}
|
||||
}
|
||||
|
||||
Graphics()->MapScreen(ScreenX0, ScreenY0, ScreenX1, ScreenY1);
|
||||
}
|
||||
|
||||
void CRenderTools::RenderSpeedupmap(CSpeedupTile *pSpeedup, int w, int h, float Scale)
|
||||
{
|
||||
float ScreenX0, ScreenY0, ScreenX1, ScreenY1;
|
||||
Graphics()->GetScreen(&ScreenX0, &ScreenY0, &ScreenX1, &ScreenY1);
|
||||
|
||||
int StartY = (int)(ScreenY0/Scale)-1;
|
||||
int StartX = (int)(ScreenX0/Scale)-1;
|
||||
int EndY = (int)(ScreenY1/Scale)+1;
|
||||
int EndX = (int)(ScreenX1/Scale)+1;
|
||||
|
||||
for(int y = StartY; y < EndY; y++)
|
||||
for(int x = StartX; x < EndX; x++)
|
||||
{
|
||||
int mx = x;
|
||||
int my = y;
|
||||
|
||||
if(mx<0)
|
||||
continue; // mx = 0;
|
||||
if(mx>=w)
|
||||
continue; // mx = w-1;
|
||||
if(my<0)
|
||||
continue; // my = 0;
|
||||
if(my>=h)
|
||||
continue; // my = h-1;
|
||||
|
||||
int c = mx + my*w;
|
||||
|
||||
int Force = (int)pSpeedup[c].m_Force;
|
||||
int MaxSpeed = (int)pSpeedup[c].m_MaxSpeed;
|
||||
if(Force)
|
||||
{
|
||||
// draw arrow
|
||||
Graphics()->TextureSet(g_pData->m_aImages[IMAGE_SPEEDUP_ARROW].m_Id);
|
||||
Graphics()->QuadsBegin();
|
||||
|
||||
SelectSprite(SPRITE_SPEEDUP_ARROW);
|
||||
Graphics()->QuadsSetRotation(pSpeedup[c].m_Angle*(3.14159265f/180.0f));
|
||||
DrawSprite(mx*Scale+16, my*Scale+16, 35.0f);
|
||||
|
||||
Graphics()->QuadsEnd();
|
||||
|
||||
// draw force
|
||||
char aBuf[16];
|
||||
str_format(aBuf, sizeof(aBuf), "%d", Force);
|
||||
UI()->TextRender()->Text(0, mx*Scale, my*Scale+16, Scale-20, aBuf, -1);
|
||||
if(MaxSpeed)
|
||||
{
|
||||
str_format(aBuf, sizeof(aBuf), "%d", MaxSpeed);
|
||||
UI()->TextRender()->Text(0, mx*Scale, my*Scale-2, Scale-20, aBuf, -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Graphics()->MapScreen(ScreenX0, ScreenY0, ScreenX1, ScreenY1);
|
||||
}
|
||||
|
||||
void CRenderTools::RenderSwitchmap(CTeleTile *pSwitch, int w, int h, float Scale)
|
||||
{
|
||||
float ScreenX0, ScreenY0, ScreenX1, ScreenY1;
|
||||
Graphics()->GetScreen(&ScreenX0, &ScreenY0, &ScreenX1, &ScreenY1);
|
||||
|
||||
int StartY = (int)(ScreenY0/Scale)-1;
|
||||
int StartX = (int)(ScreenX0/Scale)-1;
|
||||
int EndY = (int)(ScreenY1/Scale)+1;
|
||||
int EndX = (int)(ScreenX1/Scale)+1;
|
||||
|
||||
for(int y = StartY; y < EndY; y++)
|
||||
for(int x = StartX; x < EndX; x++)
|
||||
{
|
||||
int mx = x;
|
||||
int my = y;
|
||||
|
||||
|
||||
if(mx<0)
|
||||
continue; // mx = 0;
|
||||
if(mx>=w)
|
||||
continue; // mx = w-1;
|
||||
if(my<0)
|
||||
continue; // my = 0;
|
||||
if(my>=h)
|
||||
continue; // my = h-1;
|
||||
|
||||
int c = mx + my*w;
|
||||
|
||||
unsigned char Index = pSwitch[c].m_Number;
|
||||
if(Index)
|
||||
{
|
||||
char aBuf[16];
|
||||
str_format(aBuf, sizeof(aBuf), "%d", Index);
|
||||
UI()->TextRender()->Text(0, mx*Scale-2, my*Scale-4, Scale-5, aBuf, -1);
|
||||
}
|
||||
}
|
||||
|
||||
Graphics()->MapScreen(ScreenX0, ScreenY0, ScreenX1, ScreenY1);
|
||||
}
|
||||
|
|
|
@ -461,7 +461,7 @@ void CEditor::RenderBackground(CUIRect View, int Texture, float Size, float Brig
|
|||
Graphics()->QuadsEnd();
|
||||
}
|
||||
|
||||
int CEditor::UiDoValueSelector(void *pId, CUIRect *r, const char *pLabel, int Current, int Min, int Max, float Scale, const char *pToolTip)
|
||||
int CEditor::UiDoValueSelector(void *pId, CUIRect *r, const char *pLabel, int Current, int Min, int Max, int Step, float Scale, const char *pToolTip)
|
||||
{
|
||||
// logic
|
||||
static float s_Value;
|
||||
|
@ -488,7 +488,7 @@ int CEditor::UiDoValueSelector(void *pId, CUIRect *r, const char *pLabel, int Cu
|
|||
{
|
||||
int Count = (int)(s_Value/Scale);
|
||||
s_Value = fmod(s_Value, Scale);
|
||||
Current += Count;
|
||||
Current += Step*Count;
|
||||
if(Current < Min)
|
||||
Current = Min;
|
||||
if(Current > Max)
|
||||
|
@ -649,8 +649,7 @@ static void CallbackSaveMap(const char *pFileName, void *pUser)
|
|||
}
|
||||
|
||||
if(pEditor->Save(pFileName))
|
||||
if(pEditor->Save(pFileName))
|
||||
str_copy(pEditor->m_aFileName, pFileName, sizeof(pEditor->m_aFileName));
|
||||
str_copy(pEditor->m_aFileName, pFileName, sizeof(pEditor->m_aFileName));
|
||||
|
||||
pEditor->m_Dialog = DIALOG_NONE;
|
||||
}
|
||||
|
@ -792,7 +791,16 @@ void CEditor::DoToolbar(CUIRect ToolBar)
|
|||
|
||||
TB_Top.VSplitLeft(30.0f, &Button, &TB_Top);
|
||||
static int s_RotationAmount = 90;
|
||||
s_RotationAmount = UiDoValueSelector(&s_RotationAmount, &Button, "", s_RotationAmount, 1, 360, 2.0f, Localize("Rotation of the brush in degrees. Use left mouse button to drag and change the value. Hold shift to be more precise."));
|
||||
bool TileLayer = false;
|
||||
// check for tile layers in brush selection
|
||||
for(int i = 0; i < m_Brush.m_lLayers.size(); i++)
|
||||
if(m_Brush.m_lLayers[i]->m_Type == LAYERTYPE_TILES)
|
||||
{
|
||||
TileLayer = true;
|
||||
s_RotationAmount = max(90, (s_RotationAmount/90)*90);
|
||||
break;
|
||||
}
|
||||
s_RotationAmount = UiDoValueSelector(&s_RotationAmount, &Button, "", s_RotationAmount, TileLayer?90:1, 360, TileLayer?90:1, TileLayer?10.0f:2.0f, Localize("Rotation of the brush in degrees. Use left mouse button to drag and change the value. Hold shift to be more precise."));
|
||||
|
||||
TB_Top.VSplitLeft(5.0f, &Button, &TB_Top);
|
||||
TB_Top.VSplitLeft(30.0f, &Button, &TB_Top);
|
||||
|
@ -847,45 +855,11 @@ void CEditor::DoToolbar(CUIRect ToolBar)
|
|||
static int s_BorderBut = 0;
|
||||
CLayerTiles *pT = (CLayerTiles *)GetSelectedLayerType(0, LAYERTYPE_TILES);
|
||||
|
||||
// no border for tele layer and speedup
|
||||
if(pT && (pT->m_Tele || pT->m_Speedup || pT->m_Switch || pT->m_Front))
|
||||
pT = 0;
|
||||
|
||||
if(DoButton_Editor(&s_BorderBut, "Border", pT?0:-1, &Button, 0, Localize("Border")))
|
||||
if(DoButton_Editor(&s_BorderBut, Localize("Border"), pT?0:-1, &Button, 0, Localize("Border")))
|
||||
{
|
||||
if(pT)
|
||||
DoMapBorder();
|
||||
}
|
||||
|
||||
// do tele button
|
||||
TB_Bottom.VSplitLeft(5.0f, &Button, &TB_Bottom);
|
||||
TB_Bottom.VSplitLeft(60.0f, &Button, &TB_Bottom);
|
||||
static int s_TeleButton = 0;
|
||||
CLayerTiles *pS = (CLayerTiles *)GetSelectedLayerType(0, LAYERTYPE_TILES);
|
||||
|
||||
if(DoButton_Ex(&s_TeleButton, "Teleporter", (pS && pS->m_Tele)?0:-1, &Button, 0, "Teleporter", CUI::CORNER_ALL))
|
||||
{
|
||||
static int s_TelePopupId = 0;
|
||||
UiInvokePopupMenu(&s_TelePopupId, 0, UI()->MouseX(), UI()->MouseY(), 120, 23, PopupTele);
|
||||
}
|
||||
|
||||
TB_Bottom.VSplitLeft(5.0f, &Button, &TB_Bottom);
|
||||
TB_Bottom.VSplitLeft(60.0f, &Button, &TB_Bottom);
|
||||
static int s_SpeedupButton = 0;
|
||||
if(DoButton_Ex(&s_SpeedupButton, "Speedup", (pS && pS->m_Speedup)?0:-1, &Button, 0, "Speedup", CUI::CORNER_ALL))
|
||||
{
|
||||
static int s_SpeedupPopupId = 0;
|
||||
UiInvokePopupMenu(&s_SpeedupPopupId, 0, UI()->MouseX(), UI()->MouseY(), 120, 53, PopupSpeedup);
|
||||
}
|
||||
|
||||
TB_Bottom.VSplitLeft(5.0f, &Button, &TB_Bottom);
|
||||
TB_Bottom.VSplitLeft(60.0f, &Button, &TB_Bottom);
|
||||
static int s_SwitchButton = 0;
|
||||
if(DoButton_Ex(&s_SwitchButton, "Switcher", (pS && pS->m_Switch)?0:-1, &Button, 0, "Switcher", CUI::CORNER_ALL))
|
||||
{
|
||||
static int s_SwitchPopupId = 0;
|
||||
UiInvokePopupMenu(&s_SwitchPopupId, 0, UI()->MouseX(), UI()->MouseY(), 120, 23, PopupSwitch);
|
||||
}
|
||||
}
|
||||
|
||||
TB_Bottom.VSplitLeft(5.0f, 0, &TB_Bottom);
|
||||
|
@ -1204,21 +1178,12 @@ void CEditor::DoMapEditor(CUIRect View, CUIRect ToolBar)
|
|||
//UI()->ClipEnable(&view);
|
||||
}
|
||||
|
||||
// render the game, tele, speedup, front and switch above everything else
|
||||
if(m_Map.m_pGameGroup->m_Visible)
|
||||
{
|
||||
m_Map.m_pGameGroup->MapScreen();
|
||||
if(m_Map.m_pGameLayer->m_Visible)
|
||||
m_Map.m_pGameLayer->Render();
|
||||
/*if(m_Map.m_pFrontLayer && m_Map.m_pFrontLayer->m_Visible)
|
||||
m_Map.m_pFrontLayer->Render();
|
||||
if(m_Map.m_pTeleLayer && m_Map.m_pTeleLayer->m_Visible)
|
||||
m_Map.m_pTeleLayer->Render();
|
||||
if(m_Map.m_pSpeedupLayer && m_Map.m_pSpeedupLayer->m_Visible)
|
||||
m_Map.m_pSpeedupLayer->Render();
|
||||
if(m_Map.m_pSwitchLayer && m_Map.m_pSwitchLayer->m_Visible)
|
||||
m_Map.m_pSwitchLayer->Render();*/
|
||||
}
|
||||
// render the game above everything else
|
||||
if(m_Map.m_pGameGroup->m_Visible && m_Map.m_pGameLayer->m_Visible)
|
||||
{
|
||||
m_Map.m_pGameGroup->MapScreen();
|
||||
m_Map.m_pGameLayer->Render();
|
||||
}
|
||||
}
|
||||
|
||||
static void *s_pEditorId = (void *)&s_pEditorId;
|
||||
|
@ -1712,7 +1677,7 @@ int CEditor::DoProperties(CUIRect *pToolBox, CProperty *pProps, int *pIds, int *
|
|||
}
|
||||
else if(pProps[i].m_Type == PROPTYPE_INT_SCROLL)
|
||||
{
|
||||
int NewValue = UiDoValueSelector(&pIds[i], &Shifter, "", pProps[i].m_Value, pProps[i].m_Min, pProps[i].m_Max, 1.0f, Localize("Use left mouse button to drag and change the value. Hold shift to be more precise."));
|
||||
int NewValue = UiDoValueSelector(&pIds[i], &Shifter, "", pProps[i].m_Value, pProps[i].m_Min, pProps[i].m_Max, 1, 1.0f, Localize("Use left mouse button to drag and change the value. Hold shift to be more precise."));
|
||||
if(NewValue != pProps[i].m_Value)
|
||||
{
|
||||
*pNewVal = NewValue;
|
||||
|
@ -1728,7 +1693,7 @@ int CEditor::DoProperties(CUIRect *pToolBox, CProperty *pProps, int *pIds, int *
|
|||
for(int c = 0; c < 4; c++)
|
||||
{
|
||||
int v = (pProps[i].m_Value >> s_aShift[c])&0xff;
|
||||
NewColor |= UiDoValueSelector(((char *)&pIds[i])+c, &Shifter, s_paTexts[c], v, 0, 255, 1.0f, Localize("Use left mouse button to drag and change the color value. Hold shift to be more precise."))<<s_aShift[c];
|
||||
NewColor |= UiDoValueSelector(((char *)&pIds[i])+c, &Shifter, s_paTexts[c], v, 0, 255, 1, 1.0f, Localize("Use left mouse button to drag and change the color value. Hold shift to be more precise."))<<s_aShift[c];
|
||||
|
||||
if(c != 3)
|
||||
{
|
||||
|
@ -1869,8 +1834,6 @@ void CEditor::RenderLayers(CUIRect ToolBox, CUIRect ToolBar, CUIRect View)
|
|||
if(int Result = DoButton_Ex(m_Map.m_lGroups[g]->m_lLayers[i], aBuf, g==m_SelectedGroup&&i==m_SelectedLayer, &Button,
|
||||
BUTTON_CONTEXT, Localize("Select layer. Right click for properties."), CUI::CORNER_R))
|
||||
{
|
||||
/*if(m_Map.m_lGroups[g]->m_lLayers[i] == m_Map.m_pTeleLayer || m_Map.m_lGroups[g]->m_lLayers[i] == m_Map.m_pSpeedupLayer || m_Map.m_lGroups[g]->m_lLayers[i] == m_Map.m_pSwitchLayer)//Clear the brush on entering tele/speedup/switch layer
|
||||
m_Brush.Clear();*/
|
||||
m_SelectedLayer = i;
|
||||
m_SelectedGroup = g;
|
||||
static int s_LayerPopupId = 0;
|
||||
|
@ -2401,19 +2364,6 @@ void CEditor::RenderEnvelopeEditor(CUIRect View)
|
|||
CUIRect Button;
|
||||
CEnvelope *pNewEnv = 0;
|
||||
|
||||
// Delete button
|
||||
if(m_Map.m_lEnvelopes.size())
|
||||
{
|
||||
ToolBar.VSplitRight(5.0f, &ToolBar, &Button);
|
||||
ToolBar.VSplitRight(50.0f, &ToolBar, &Button);
|
||||
static int s_DelButton = 0;
|
||||
if(DoButton_Editor(&s_DelButton, Localize("Delete"), 0, &Button, 0, Localize("Delete this envelope")))
|
||||
m_Map.DeleteEnvelope(m_SelectedEnvelope);
|
||||
|
||||
// little space
|
||||
ToolBar.VSplitRight(10.0f, &ToolBar, &Button);
|
||||
}
|
||||
|
||||
ToolBar.VSplitRight(50.0f, &ToolBar, &Button);
|
||||
static int s_New4dButton = 0;
|
||||
if(DoButton_Editor(&s_New4dButton, Localize("Color+"), 0, &Button, 0, Localize("Creates a new color envelope")))
|
||||
|
@ -2424,7 +2374,7 @@ void CEditor::RenderEnvelopeEditor(CUIRect View)
|
|||
static int s_New2dButton = 0;
|
||||
if(DoButton_Editor(&s_New2dButton, Localize("Pos.+"), 0, &Button, 0, Localize("Creates a new pos envelope")))
|
||||
pNewEnv = m_Map.NewEnvelope(3);
|
||||
|
||||
|
||||
// Delete button
|
||||
if(m_SelectedEnvelope >= 0)
|
||||
{
|
||||
|
@ -3061,34 +3011,6 @@ void CEditorMap::MakeGameLayer(CLayer *pLayer)
|
|||
m_pGameLayer->m_TexId = m_pEditor->ms_EntitiesTexture;
|
||||
}
|
||||
|
||||
void CEditorMap::MakeTeleLayer(CLayer *pLayer)
|
||||
{
|
||||
m_pTeleLayer = (CLayerTele *)pLayer;
|
||||
m_pTeleLayer->m_pEditor = m_pEditor;
|
||||
m_pTeleLayer->m_TexId = m_pEditor->ms_EntitiesTexture;
|
||||
}
|
||||
|
||||
void CEditorMap::MakeSpeedupLayer(CLayer *pLayer)
|
||||
{
|
||||
m_pSpeedupLayer = (CLayerSpeedup *)pLayer;
|
||||
m_pSpeedupLayer->m_pEditor = m_pEditor;
|
||||
m_pSpeedupLayer->m_TexId = m_pEditor->ms_EntitiesTexture;
|
||||
}
|
||||
|
||||
void CEditorMap::MakeFrontLayer(CLayer *pLayer)
|
||||
{
|
||||
m_pFrontLayer = (CLayerFront *)pLayer;
|
||||
m_pFrontLayer->m_pEditor = m_pEditor;
|
||||
m_pFrontLayer->m_TexId = m_pEditor->ms_EntitiesTexture;
|
||||
}
|
||||
|
||||
void CEditorMap::MakeSwitchLayer(CLayer *pLayer)
|
||||
{
|
||||
m_pSwitchLayer = (CLayerSwitch *)pLayer;
|
||||
m_pSwitchLayer->m_pEditor = m_pEditor;
|
||||
m_pSwitchLayer->m_TexId = m_pEditor->ms_EntitiesTexture;
|
||||
}
|
||||
|
||||
void CEditorMap::MakeGameGroup(CLayerGroup *pGroup)
|
||||
{
|
||||
m_pGameGroup = pGroup;
|
||||
|
@ -3105,10 +3027,6 @@ void CEditorMap::Clean()
|
|||
m_lImages.delete_all();
|
||||
|
||||
m_pGameLayer = 0x0;
|
||||
m_pTeleLayer = 0x0;
|
||||
m_pSpeedupLayer = 0x0;
|
||||
m_pFrontLayer = 0x0;
|
||||
m_pSwitchLayer = 0x0;
|
||||
m_pGameGroup = 0x0;
|
||||
}
|
||||
|
||||
|
@ -3135,15 +3053,10 @@ void CEditorMap::CreateDefault(int EntitiesTexture)
|
|||
pQuad->m_aColors[2].b = pQuad->m_aColors[3].b = 255;
|
||||
pGroup->AddLayer(pLayer);
|
||||
|
||||
// add game layer and front
|
||||
// add game layer
|
||||
MakeGameGroup(NewGroup());
|
||||
MakeGameLayer(new CLayerGame(50, 50));
|
||||
MakeFrontLayer(new CLayerFront(50, 50));
|
||||
m_pGameGroup->AddLayer(m_pGameLayer);
|
||||
m_pGameGroup->AddLayer(m_pFrontLayer);
|
||||
m_pTeleLayer = 0x0;
|
||||
m_pSpeedupLayer = 0x0;
|
||||
m_pSwitchLayer = 0x0;
|
||||
}
|
||||
|
||||
void CEditor::Init()
|
||||
|
|
|
@ -132,6 +132,7 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
|
||||
virtual void BrushSelecting(CUIRect Rect) {}
|
||||
virtual int BrushGrab(CLayerGroup *pBrush, CUIRect Rect) { return 0; }
|
||||
virtual void FillSelection(bool Empty, CLayer *pBrush, CUIRect Rect) {}
|
||||
|
@ -265,10 +266,6 @@ public:
|
|||
array<CEnvelope*> m_lEnvelopes;
|
||||
|
||||
class CLayerGame *m_pGameLayer;
|
||||
class CLayerTele *m_pTeleLayer;
|
||||
class CLayerSpeedup *m_pSpeedupLayer;
|
||||
class CLayerFront *m_pFrontLayer;
|
||||
class CLayerSwitch *m_pSwitchLayer;
|
||||
CLayerGroup *m_pGameGroup;
|
||||
|
||||
CEnvelope *NewEnvelope(int Channels)
|
||||
|
@ -322,11 +319,6 @@ public:
|
|||
// io
|
||||
int Save(class IStorage *pStorage, const char *pFilename);
|
||||
int Load(class IStorage *pStorage, const char *pFilename);
|
||||
|
||||
void MakeTeleLayer(CLayer *pLayer);
|
||||
void MakeSpeedupLayer(CLayer *pLayer);
|
||||
void MakeFrontLayer(CLayer *pLayer);
|
||||
void MakeSwitchLayer(CLayer *pLayer);
|
||||
};
|
||||
|
||||
|
||||
|
@ -362,7 +354,7 @@ public:
|
|||
CLayerTiles(int w, int h);
|
||||
~CLayerTiles();
|
||||
|
||||
virtual void Resize(int NewW, int NewH);
|
||||
void Resize(int NewW, int NewH);
|
||||
|
||||
void MakePalette();
|
||||
virtual void Render();
|
||||
|
@ -380,7 +372,7 @@ public:
|
|||
virtual void BrushFlipX();
|
||||
virtual void BrushFlipY();
|
||||
virtual void BrushRotate(float Amount);
|
||||
|
||||
|
||||
virtual int RenderProperties(CUIRect *pToolbox);
|
||||
|
||||
virtual void ModifyImageIndex(INDEX_MODIFY_FUNC pfnFunc);
|
||||
|
@ -392,10 +384,6 @@ public:
|
|||
|
||||
int m_TexId;
|
||||
int m_Game;
|
||||
int m_Tele;
|
||||
int m_Speedup;
|
||||
int m_Front;
|
||||
int m_Switch;
|
||||
int m_Image;
|
||||
int m_Width;
|
||||
int m_Height;
|
||||
|
@ -410,7 +398,7 @@ public:
|
|||
|
||||
virtual void Render();
|
||||
CQuad *NewQuad();
|
||||
|
||||
|
||||
virtual void BrushSelecting(CUIRect Rect);
|
||||
virtual int BrushGrab(CLayerGroup *pBrush, CUIRect Rect);
|
||||
virtual void BrushPlace(CLayer *pBrush, float wx, float wy);
|
||||
|
@ -438,55 +426,6 @@ public:
|
|||
virtual int RenderProperties(CUIRect *pToolbox);
|
||||
};
|
||||
|
||||
class CLayerTele : public CLayerTiles
|
||||
{
|
||||
public:
|
||||
CLayerTele(int w, int h);
|
||||
~CLayerTele();
|
||||
|
||||
CTeleTile *m_pTeleTile;
|
||||
|
||||
virtual void Resize(int NewW, int NewH);
|
||||
virtual void BrushDraw(CLayer *pBrush, float wx, float wy);
|
||||
virtual void FillSelection(bool Empty, CLayer *pBrush, CUIRect Rect);
|
||||
};
|
||||
|
||||
class CLayerSpeedup : public CLayerTiles
|
||||
{
|
||||
public:
|
||||
CLayerSpeedup(int w, int h);
|
||||
~CLayerSpeedup();
|
||||
|
||||
CSpeedupTile *m_pSpeedupTile;
|
||||
|
||||
virtual void Resize(int NewW, int NewH);
|
||||
virtual void BrushDraw(CLayer *pBrush, float wx, float wy);
|
||||
virtual void FillSelection(bool Empty, CLayer *pBrush, CUIRect Rect);
|
||||
};
|
||||
|
||||
class CLayerFront : public CLayerTiles
|
||||
{
|
||||
public:
|
||||
CLayerFront(int w, int h);
|
||||
|
||||
virtual void Resize(int NewW, int NewH);
|
||||
virtual void BrushDraw(CLayer *pBrush, float wx, float wy);
|
||||
};
|
||||
|
||||
class CLayerSwitch : public CLayerTiles
|
||||
{
|
||||
public:
|
||||
CLayerSwitch(int w, int h);
|
||||
~CLayerSwitch();
|
||||
|
||||
CTeleTile *m_pSwitchTile;
|
||||
|
||||
virtual void Resize(int NewW, int NewH);
|
||||
virtual void BrushDraw(CLayer *pBrush, float wx, float wy);
|
||||
virtual void FillSelection(bool Empty, CLayer *pBrush, CUIRect Rect);
|
||||
};
|
||||
|
||||
|
||||
class CEditor : public IEditor
|
||||
{
|
||||
class IInput *m_pInput;
|
||||
|
@ -563,13 +502,6 @@ public:
|
|||
ms_EntitiesTexture = 0;
|
||||
|
||||
ms_pUiGotContext = 0;
|
||||
|
||||
m_TeleNum = 1;
|
||||
m_SwitchNum = 1;
|
||||
|
||||
m_SpeedupForce = 50;
|
||||
m_SpeedupMaxSpeed = 0;
|
||||
m_SpeedupAngle = 0;
|
||||
}
|
||||
|
||||
virtual void Init();
|
||||
|
@ -676,7 +608,7 @@ public:
|
|||
void UiInvokePopupMenu(void *pId, int Flags, float x, float y, float w, float h, int (*pfnFunc)(CEditor *pEditor, CUIRect Rect), void *pExtra=0);
|
||||
void UiDoPopupMenu();
|
||||
|
||||
int UiDoValueSelector(void *pId, CUIRect *r, const char *pLabel, int Current, int Min, int Max, float Scale, const char *pToolTip);
|
||||
int UiDoValueSelector(void *pId, CUIRect *r, const char *pLabel, int Current, int Min, int Max, int Step, float Scale, const char *pToolTip);
|
||||
|
||||
static int PopupGroup(CEditor *pEditor, CUIRect View);
|
||||
static int PopupLayer(CEditor *pEditor, CUIRect View);
|
||||
|
@ -685,9 +617,6 @@ public:
|
|||
static int PopupSelectImage(CEditor *pEditor, CUIRect View);
|
||||
static int PopupImage(CEditor *pEditor, CUIRect View);
|
||||
static int PopupMenuFile(CEditor *pEditor, CUIRect View);
|
||||
static int PopupTele(CEditor *pEditor, CUIRect View);
|
||||
static int PopupSpeedup(CEditor *pEditor, CUIRect View);
|
||||
static int PopupSwitch(CEditor *pEditor, CUIRect View);
|
||||
|
||||
|
||||
void PopupSelectImageInvoke(int Current, float x, float y);
|
||||
|
@ -716,14 +645,6 @@ public:
|
|||
|
||||
void AddFileDialogEntry(const char *pName, CUIRect *pView);
|
||||
void SortImages();
|
||||
|
||||
unsigned char m_TeleNum;
|
||||
|
||||
unsigned char m_SpeedupForce;
|
||||
unsigned char m_SpeedupMaxSpeed;
|
||||
short m_SpeedupAngle;
|
||||
|
||||
unsigned char m_SwitchNum;
|
||||
};
|
||||
|
||||
// make sure to inline this function
|
||||
|
|
|
@ -282,51 +282,9 @@ int CEditorMap::Save(class IStorage *pStorage, const char *pFileName)
|
|||
|
||||
Item.m_Width = pLayer->m_Width;
|
||||
Item.m_Height = pLayer->m_Height;
|
||||
if(pLayer->m_Tele)
|
||||
Item.m_Flags = 2;
|
||||
else if(pLayer->m_Speedup)
|
||||
Item.m_Flags = 4;
|
||||
else if(pLayer->m_Front)
|
||||
Item.m_Flags = 8;
|
||||
else if(pLayer->m_Switch)
|
||||
Item.m_Flags = 16;
|
||||
else
|
||||
Item.m_Flags = pLayer->m_Game;
|
||||
Item.m_Flags = pLayer->m_Game;
|
||||
Item.m_Image = pLayer->m_Image;
|
||||
if(pLayer->m_Tele)
|
||||
{
|
||||
CTile *Tiles = new CTile[pLayer->m_Width*pLayer->m_Height];
|
||||
mem_zero(Tiles, pLayer->m_Width*pLayer->m_Height*sizeof(CTile));
|
||||
Item.m_Data = df.AddData(pLayer->m_Width*pLayer->m_Height*sizeof(CTile), Tiles);
|
||||
Item.m_Tele = df.AddData(pLayer->m_Width*pLayer->m_Height*sizeof(CTeleTile), ((CLayerTele *)pLayer)->m_pTeleTile);
|
||||
delete[] Tiles;
|
||||
}
|
||||
else if(pLayer->m_Speedup)
|
||||
{
|
||||
CTile *Tiles = new CTile[pLayer->m_Width*pLayer->m_Height];
|
||||
mem_zero(Tiles, pLayer->m_Width*pLayer->m_Height*sizeof(CTile));
|
||||
Item.m_Data = df.AddData(pLayer->m_Width*pLayer->m_Height*sizeof(CTile), Tiles);
|
||||
Item.m_Speedup = df.AddData(pLayer->m_Width*pLayer->m_Height*sizeof(CSpeedupTile), ((CLayerSpeedup *)pLayer)->m_pSpeedupTile);
|
||||
delete[] Tiles;
|
||||
}
|
||||
else if(pLayer->m_Front)
|
||||
{
|
||||
CTile *Tiles = new CTile[pLayer->m_Width*pLayer->m_Height];
|
||||
mem_zero(Tiles, pLayer->m_Width*pLayer->m_Height*sizeof(CTile));
|
||||
Item.m_Data = df.AddData(pLayer->m_Width*pLayer->m_Height*sizeof(CTile), Tiles);
|
||||
Item.m_Front = df.AddData(pLayer->m_Width*pLayer->m_Height*sizeof(CTile), pLayer->m_pTiles);//Thanks Sushi Tee
|
||||
delete[] Tiles;
|
||||
}
|
||||
else if(pLayer->m_Switch)
|
||||
{
|
||||
CTile *Tiles = new CTile[pLayer->m_Width*pLayer->m_Height];
|
||||
mem_zero(Tiles, pLayer->m_Width*pLayer->m_Height*sizeof(CTile));
|
||||
Item.m_Data = df.AddData(pLayer->m_Width*pLayer->m_Height*sizeof(CTile), Tiles);
|
||||
Item.m_Switch = df.AddData(pLayer->m_Width*pLayer->m_Height*sizeof(CTeleTile), ((CLayerSwitch *)pLayer)->m_pSwitchTile);
|
||||
delete[] Tiles;
|
||||
}
|
||||
else
|
||||
Item.m_Data = df.AddData(pLayer->m_Width*pLayer->m_Height*sizeof(CTile), pLayer->m_pTiles);
|
||||
Item.m_Data = df.AddData(pLayer->m_Width*pLayer->m_Height*sizeof(CTile), pLayer->m_pTiles);
|
||||
df.AddItem(MAPITEMTYPE_LAYER, LayerCount, sizeof(Item), &Item);
|
||||
|
||||
GItem.m_NumLayers++;
|
||||
|
@ -532,26 +490,6 @@ int CEditorMap::Load(class IStorage *pStorage, const char *pFileName)
|
|||
MakeGameLayer(pTiles);
|
||||
MakeGameGroup(pGroup);
|
||||
}
|
||||
else if(pTilemapItem->m_Flags&2)
|
||||
{
|
||||
pTiles = new CLayerTele(pTilemapItem->m_Width, pTilemapItem->m_Height);
|
||||
MakeTeleLayer(pTiles);
|
||||
}
|
||||
else if(pTilemapItem->m_Flags&4)
|
||||
{
|
||||
pTiles = new CLayerSpeedup(pTilemapItem->m_Width, pTilemapItem->m_Height);
|
||||
MakeSpeedupLayer(pTiles);
|
||||
}
|
||||
else if(pTilemapItem->m_Flags&8)
|
||||
{
|
||||
pTiles = new CLayerFront(pTilemapItem->m_Width, pTilemapItem->m_Height);
|
||||
MakeFrontLayer(pTiles);
|
||||
}
|
||||
else if(pTilemapItem->m_Flags&16)
|
||||
{
|
||||
pTiles = new CLayerSwitch(pTilemapItem->m_Width, pTilemapItem->m_Height);
|
||||
MakeSwitchLayer(pTiles);
|
||||
}
|
||||
else
|
||||
{
|
||||
pTiles = new CLayerTiles(pTilemapItem->m_Width, pTilemapItem->m_Height);
|
||||
|
@ -577,69 +515,6 @@ int CEditorMap::Load(class IStorage *pStorage, const char *pFileName)
|
|||
}
|
||||
|
||||
DataFile.UnloadData(pTilemapItem->m_Data);
|
||||
|
||||
if(pTiles->m_Tele)
|
||||
{
|
||||
void *pTeleData = DataFile.GetData(pTilemapItem->m_Tele);
|
||||
mem_copy(((CLayerTele*)pTiles)->m_pTeleTile, pTeleData, pTiles->m_Width*pTiles->m_Height*sizeof(CTeleTile));
|
||||
|
||||
for(int i = 0; i < pTiles->m_Width*pTiles->m_Height; i++)
|
||||
{
|
||||
if(((CLayerTele*)pTiles)->m_pTeleTile[i].m_Type == TILE_TELEIN)
|
||||
((CLayerTiles*)pTiles)->m_pTiles[i].m_Index = TILE_TELEIN;
|
||||
else if(((CLayerTele*)pTiles)->m_pTeleTile[i].m_Type == TILE_TELEINEVIL)
|
||||
((CLayerTiles*)pTiles)->m_pTiles[i].m_Index = TILE_TELEINEVIL;
|
||||
else if(((CLayerTele*)pTiles)->m_pTeleTile[i].m_Type == TILE_TELEOUT)
|
||||
((CLayerTiles*)pTiles)->m_pTiles[i].m_Index = TILE_TELEOUT;
|
||||
else
|
||||
((CLayerTiles*)pTiles)->m_pTiles[i].m_Index = 0;
|
||||
}
|
||||
DataFile.UnloadData(pTilemapItem->m_Tele);
|
||||
}
|
||||
else if(pTiles->m_Speedup)
|
||||
{
|
||||
void *pSpeedupData = DataFile.GetData(pTilemapItem->m_Speedup);
|
||||
mem_copy(((CLayerSpeedup*)pTiles)->m_pSpeedupTile, pSpeedupData, pTiles->m_Width*pTiles->m_Height*sizeof(CSpeedupTile));
|
||||
|
||||
for(int i = 0; i < pTiles->m_Width*pTiles->m_Height; i++)
|
||||
{
|
||||
if(((CLayerSpeedup*)pTiles)->m_pSpeedupTile[i].m_Force > 0 && (((CLayerSpeedup*)pTiles)->m_pSpeedupTile[i].m_Type == TILE_BOOST || ((CLayerSpeedup*)pTiles)->m_pSpeedupTile[i].m_Type == TILE_BOOSTS))
|
||||
((CLayerTiles*)pTiles)->m_pTiles[i].m_Index = ((CLayerSpeedup*)pTiles)->m_pSpeedupTile[i].m_Type;
|
||||
else
|
||||
((CLayerTiles*)pTiles)->m_pTiles[i].m_Index = 0;
|
||||
}
|
||||
|
||||
DataFile.UnloadData(pTilemapItem->m_Speedup);
|
||||
}
|
||||
else if(pTiles->m_Front)
|
||||
{
|
||||
void *pFrontData = DataFile.GetData(pTilemapItem->m_Front);
|
||||
mem_copy(((CLayerFront*)pTiles)->m_pTiles, pFrontData, pTiles->m_Width*pTiles->m_Height*sizeof(CTile));
|
||||
|
||||
DataFile.UnloadData(pTilemapItem->m_Front);
|
||||
}
|
||||
else if(pTiles->m_Switch)
|
||||
{
|
||||
void *pSwitchData = DataFile.GetData(pTilemapItem->m_Switch);
|
||||
mem_copy(((CLayerSwitch*)pTiles)->m_pSwitchTile, pSwitchData, pTiles->m_Width*pTiles->m_Height*sizeof(CTeleTile));
|
||||
|
||||
for(int i = 0; i < pTiles->m_Width*pTiles->m_Height; i++)
|
||||
{
|
||||
if(((CLayerSwitch*)pTiles)->m_pSwitchTile[i].m_Type == (ENTITY_TRIGGER + ENTITY_OFFSET))
|
||||
((CLayerTiles*)pTiles)->m_pTiles[i].m_Index = (ENTITY_TRIGGER + ENTITY_OFFSET);
|
||||
else if(((CLayerSwitch*)pTiles)->m_pSwitchTile[i].m_Type == (ENTITY_DOOR + ENTITY_OFFSET))
|
||||
((CLayerTiles*)pTiles)->m_pTiles[i].m_Index = (ENTITY_DOOR + ENTITY_OFFSET);
|
||||
else if(((CLayerSwitch*)pTiles)->m_pSwitchTile[i].m_Type == (ENTITY_LASER_SHORT + ENTITY_OFFSET))
|
||||
((CLayerTiles*)pTiles)->m_pTiles[i].m_Index = (ENTITY_LASER_SHORT + ENTITY_OFFSET);
|
||||
else if(((CLayerSwitch*)pTiles)->m_pSwitchTile[i].m_Type == (ENTITY_LASER_MIDDLE + ENTITY_OFFSET))
|
||||
((CLayerTiles*)pTiles)->m_pTiles[i].m_Index = (ENTITY_LASER_MIDDLE + ENTITY_OFFSET);
|
||||
else if(((CLayerSwitch*)pTiles)->m_pSwitchTile[i].m_Type == (ENTITY_LASER_LONG + ENTITY_OFFSET))
|
||||
((CLayerTiles*)pTiles)->m_pTiles[i].m_Index = (ENTITY_LASER_LONG + ENTITY_OFFSET);
|
||||
else
|
||||
((CLayerTiles*)pTiles)->m_pTiles[i].m_Index = 0;
|
||||
}
|
||||
DataFile.UnloadData(pTilemapItem->m_Switch);
|
||||
}
|
||||
}
|
||||
else if(pLayerItem->m_Type == LAYERTYPE_QUADS)
|
||||
{
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
#include <engine/graphics.h>
|
||||
#include <engine/textrender.h>
|
||||
#include <engine/input.h>
|
||||
#include <engine/keys.h>
|
||||
|
||||
#include <game/generated/client_data.h>
|
||||
#include <game/client/render.h>
|
||||
|
@ -20,10 +18,6 @@ CLayerTiles::CLayerTiles(int w, int h)
|
|||
m_Image = -1;
|
||||
m_TexId = -1;
|
||||
m_Game = 0;
|
||||
m_Tele = 0;
|
||||
m_Speedup = 0;
|
||||
m_Front = 0;
|
||||
m_Switch = 0;
|
||||
|
||||
m_pTiles = new CTile[m_Width*m_Height];
|
||||
mem_zero(m_pTiles, m_Width*m_Height*sizeof(CTile));
|
||||
|
@ -61,12 +55,6 @@ void CLayerTiles::Render()
|
|||
m_TexId = m_pEditor->m_Map.m_lImages[m_Image]->m_TexId;
|
||||
Graphics()->TextureSet(m_TexId);
|
||||
m_pEditor->RenderTools()->RenderTilemap(m_pTiles, m_Width, m_Height, 32.0f, vec4(1,1,1,1), LAYERRENDERFLAG_OPAQUE|LAYERRENDERFLAG_TRANSPARENT);
|
||||
if(m_Tele)
|
||||
m_pEditor->RenderTools()->RenderTelemap(((CLayerTele*)this)->m_pTeleTile, m_Width, m_Height, 32.0f);
|
||||
if(m_Speedup)
|
||||
m_pEditor->RenderTools()->RenderSpeedupmap(((CLayerSpeedup*)this)->m_pSpeedupTile, m_Width, m_Height, 32.0f);
|
||||
if(m_Switch)
|
||||
m_pEditor->RenderTools()->RenderSwitchmap(((CLayerSwitch*)this)->m_pSwitchTile, m_Width, m_Height, 32.0f);
|
||||
}
|
||||
|
||||
int CLayerTiles::ConvertX(float x) const { return (int)(x/32.0f); }
|
||||
|
@ -140,100 +128,17 @@ int CLayerTiles::BrushGrab(CLayerGroup *pBrush, CUIRect Rect)
|
|||
return 0;
|
||||
|
||||
// create new layers
|
||||
if(m_pEditor->GetSelectedLayer(0) == m_pEditor->m_Map.m_pTeleLayer)
|
||||
{
|
||||
CLayerTele *pGrabbed = new CLayerTele(r.w, r.h);
|
||||
pGrabbed->m_pEditor = m_pEditor;
|
||||
pGrabbed->m_TexId = m_TexId;
|
||||
pGrabbed->m_Image = m_Image;
|
||||
pGrabbed->m_Game = m_Game;
|
||||
|
||||
pBrush->AddLayer(pGrabbed);
|
||||
|
||||
// copy the tiles
|
||||
for(int y = 0; y < r.h; y++)
|
||||
for(int x = 0; x < r.w; x++)
|
||||
pGrabbed->m_pTiles[y*pGrabbed->m_Width+x] = m_pTiles[(r.y+y)*m_Width+(r.x+x)];
|
||||
|
||||
// copy the tele data
|
||||
if(!m_pEditor->Input()->KeyPressed(KEY_SPACE))
|
||||
for(int y = 0; y < r.h; y++)
|
||||
for(int x = 0; x < r.w; x++)
|
||||
{
|
||||
pGrabbed->m_pTeleTile[y*pGrabbed->m_Width+x] = ((CLayerTele*)this)->m_pTeleTile[(r.y+y)*m_Width+(r.x+x)];
|
||||
if(pGrabbed->m_pTeleTile[y*pGrabbed->m_Width+x].m_Type == TILE_TELEIN || pGrabbed->m_pTeleTile[y*pGrabbed->m_Width+x].m_Type == TILE_TELEOUT || pGrabbed->m_pTeleTile[y*pGrabbed->m_Width+x].m_Type == TILE_TELEINEVIL)
|
||||
m_pEditor->m_TeleNum = pGrabbed->m_pTeleTile[y*pGrabbed->m_Width+x].m_Number;
|
||||
}
|
||||
}
|
||||
else if(m_pEditor->GetSelectedLayer(0) == m_pEditor->m_Map.m_pSpeedupLayer)
|
||||
{
|
||||
CLayerSpeedup *pGrabbed = new CLayerSpeedup(r.w, r.h);
|
||||
pGrabbed->m_pEditor = m_pEditor;
|
||||
pGrabbed->m_TexId = m_TexId;
|
||||
pGrabbed->m_Image = m_Image;
|
||||
pGrabbed->m_Game = m_Game;
|
||||
|
||||
pBrush->AddLayer(pGrabbed);
|
||||
|
||||
// copy the tiles
|
||||
for(int y = 0; y < r.h; y++)
|
||||
for(int x = 0; x < r.w; x++)
|
||||
pGrabbed->m_pTiles[y*pGrabbed->m_Width+x] = m_pTiles[(r.y+y)*m_Width+(r.x+x)];
|
||||
|
||||
// copy the speedup data
|
||||
if(!m_pEditor->Input()->KeyPressed(KEY_SPACE))
|
||||
for(int y = 0; y < r.h; y++)
|
||||
for(int x = 0; x < r.w; x++)
|
||||
{
|
||||
pGrabbed->m_pSpeedupTile[y*pGrabbed->m_Width+x] = ((CLayerSpeedup*)this)->m_pSpeedupTile[(r.y+y)*m_Width+(r.x+x)];
|
||||
if(pGrabbed->m_pSpeedupTile[y*pGrabbed->m_Width+x].m_Type == TILE_BOOST || pGrabbed->m_pSpeedupTile[y*pGrabbed->m_Width+x].m_Type == TILE_BOOSTS)
|
||||
{
|
||||
m_pEditor->m_SpeedupAngle = pGrabbed->m_pSpeedupTile[y*pGrabbed->m_Width+x].m_Angle;
|
||||
m_pEditor->m_SpeedupForce = pGrabbed->m_pSpeedupTile[y*pGrabbed->m_Width+x].m_Force;
|
||||
m_pEditor->m_SpeedupMaxSpeed = pGrabbed->m_pSpeedupTile[y*pGrabbed->m_Width+x].m_MaxSpeed;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(m_pEditor->GetSelectedLayer(0) == m_pEditor->m_Map.m_pSwitchLayer)
|
||||
{
|
||||
CLayerSwitch *pGrabbed = new CLayerSwitch(r.w, r.h);
|
||||
pGrabbed->m_pEditor = m_pEditor;
|
||||
pGrabbed->m_TexId = m_TexId;
|
||||
pGrabbed->m_Image = m_Image;
|
||||
pGrabbed->m_Game = m_Game;
|
||||
|
||||
pBrush->AddLayer(pGrabbed);
|
||||
|
||||
// copy the tiles
|
||||
for(int y = 0; y < r.h; y++)
|
||||
for(int x = 0; x < r.w; x++)
|
||||
pGrabbed->m_pTiles[y*pGrabbed->m_Width+x] = m_pTiles[(r.y+y)*m_Width+(r.x+x)];
|
||||
|
||||
// copy the switch data
|
||||
if(!m_pEditor->Input()->KeyPressed(KEY_SPACE))
|
||||
for(int y = 0; y < r.h; y++)
|
||||
for(int x = 0; x < r.w; x++)
|
||||
{
|
||||
pGrabbed->m_pSwitchTile[y*pGrabbed->m_Width+x] = ((CLayerSwitch*)this)->m_pSwitchTile[(r.y+y)*m_Width+(r.x+x)];
|
||||
if(pGrabbed->m_pSwitchTile[y*pGrabbed->m_Width+x].m_Type == ENTITY_DOOR + ENTITY_OFFSET || pGrabbed->m_pSwitchTile[y*pGrabbed->m_Width+x].m_Type == ENTITY_TRIGGER + ENTITY_OFFSET || pGrabbed->m_pSwitchTile[y*pGrabbed->m_Width+x].m_Type == ENTITY_LASER_LONG + ENTITY_OFFSET || pGrabbed->m_pSwitchTile[y*pGrabbed->m_Width+x].m_Type == ENTITY_LASER_MIDDLE + ENTITY_OFFSET || pGrabbed->m_pSwitchTile[y*pGrabbed->m_Width+x].m_Type == ENTITY_LASER_SHORT + ENTITY_OFFSET)
|
||||
m_pEditor->m_SwitchNum = pGrabbed->m_pSwitchTile[y*pGrabbed->m_Width+x].m_Number;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CLayerTiles *pGrabbed = new CLayerTiles(r.w, r.h);
|
||||
pGrabbed->m_pEditor = m_pEditor;
|
||||
pGrabbed->m_TexId = m_TexId;
|
||||
pGrabbed->m_Image = m_Image;
|
||||
pGrabbed->m_Game = m_Game;
|
||||
|
||||
pBrush->AddLayer(pGrabbed);
|
||||
|
||||
// copy the tiles
|
||||
for(int y = 0; y < r.h; y++)
|
||||
for(int x = 0; x < r.w; x++)
|
||||
pGrabbed->m_pTiles[y*pGrabbed->m_Width+x] = m_pTiles[(r.y+y)*m_Width+(r.x+x)];
|
||||
}
|
||||
CLayerTiles *pGrabbed = new CLayerTiles(r.w, r.h);
|
||||
pGrabbed->m_pEditor = m_pEditor;
|
||||
pGrabbed->m_TexId = m_TexId;
|
||||
pGrabbed->m_Image = m_Image;
|
||||
pGrabbed->m_Game = m_Game;
|
||||
pBrush->AddLayer(pGrabbed);
|
||||
|
||||
// copy the tiles
|
||||
for(int y = 0; y < r.h; y++)
|
||||
for(int x = 0; x < r.w; x++)
|
||||
pGrabbed->m_pTiles[y*pGrabbed->m_Width+x] = m_pTiles[(r.y+y)*m_Width+(r.x+x)];
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -286,10 +191,6 @@ void CLayerTiles::BrushDraw(CLayer *pBrush, float wx, float wy)
|
|||
if(fx<0 || fx >= m_Width || fy < 0 || fy >= m_Height)
|
||||
continue;
|
||||
|
||||
// dont allow tele in and out tiles... same with speedup tile in game layer
|
||||
if(m_pEditor->GetSelectedLayer(0) == m_pEditor->m_Map.m_pGameLayer && (l->m_pTiles[y*l->m_Width+x].m_Index == TILE_TELEIN || l->m_pTiles[y*l->m_Width+x].m_Index == TILE_TELEINEVIL || l->m_pTiles[y*l->m_Width+x].m_Index == TILE_TELEOUT || l->m_pTiles[y*l->m_Width+x].m_Index == TILE_BOOST || l->m_pTiles[y*l->m_Width+x].m_Index == TILE_BOOSTS || l->m_pTiles[y*l->m_Width+x].m_Index == (ENTITY_TRIGGER + ENTITY_OFFSET)|| l->m_pTiles[y*l->m_Width+x].m_Index == (ENTITY_DOOR + ENTITY_OFFSET)))
|
||||
continue;
|
||||
|
||||
m_pTiles[fy*m_Width+fx] = l->m_pTiles[y*l->m_Width+x];
|
||||
}
|
||||
}
|
||||
|
@ -304,9 +205,10 @@ void CLayerTiles::BrushFlipX()
|
|||
m_pTiles[y*m_Width+m_Width-1-x] = Tmp;
|
||||
}
|
||||
|
||||
for(int y = 0; y < m_Height; y++)
|
||||
for(int x = 0; x < m_Width; x++)
|
||||
m_pTiles[y*m_Width+x].m_Flags ^= m_pTiles[y*m_Width+x].m_Flags&TILEFLAG_ROTATE ? TILEFLAG_HFLIP : TILEFLAG_VFLIP;
|
||||
if(!m_Game)
|
||||
for(int y = 0; y < m_Height; y++)
|
||||
for(int x = 0; x < m_Width; x++)
|
||||
m_pTiles[y*m_Width+x].m_Flags ^= m_pTiles[y*m_Width+x].m_Flags&TILEFLAG_ROTATE ? TILEFLAG_HFLIP : TILEFLAG_VFLIP;
|
||||
}
|
||||
|
||||
void CLayerTiles::BrushFlipY()
|
||||
|
@ -319,9 +221,10 @@ void CLayerTiles::BrushFlipY()
|
|||
m_pTiles[(m_Height-1-y)*m_Width+x] = Tmp;
|
||||
}
|
||||
|
||||
for(int y = 0; y < m_Height; y++)
|
||||
for(int x = 0; x < m_Width; x++)
|
||||
m_pTiles[y*m_Width+x].m_Flags ^= m_pTiles[y*m_Width+x].m_Flags&TILEFLAG_ROTATE ? TILEFLAG_VFLIP : TILEFLAG_HFLIP;
|
||||
if(!m_Game)
|
||||
for(int y = 0; y < m_Height; y++)
|
||||
for(int x = 0; x < m_Width; x++)
|
||||
m_pTiles[y*m_Width+x].m_Flags ^= m_pTiles[y*m_Width+x].m_Flags&TILEFLAG_ROTATE ? TILEFLAG_VFLIP : TILEFLAG_HFLIP;
|
||||
}
|
||||
|
||||
void CLayerTiles::BrushRotate(float Amount)
|
||||
|
@ -340,9 +243,12 @@ void CLayerTiles::BrushRotate(float Amount)
|
|||
for(int y = m_Height-1; y >= 0; --y, ++pDst)
|
||||
{
|
||||
*pDst = pTempData[y*m_Width+x];
|
||||
if(pDst->m_Flags&TILEFLAG_ROTATE)
|
||||
pDst->m_Flags ^= (TILEFLAG_HFLIP|TILEFLAG_VFLIP);
|
||||
pDst->m_Flags ^= TILEFLAG_ROTATE;
|
||||
if(!m_Game)
|
||||
{
|
||||
if(pDst->m_Flags&TILEFLAG_ROTATE)
|
||||
pDst->m_Flags ^= (TILEFLAG_HFLIP|TILEFLAG_VFLIP);
|
||||
pDst->m_Flags ^= TILEFLAG_ROTATE;
|
||||
}
|
||||
}
|
||||
|
||||
int Temp = m_Width;
|
||||
|
@ -372,23 +278,6 @@ void CLayerTiles::Resize(int NewW, int NewH)
|
|||
m_pTiles = pNewData;
|
||||
m_Width = NewW;
|
||||
m_Height = NewH;
|
||||
|
||||
// resize tele layer if available
|
||||
if(m_Game && m_pEditor->m_Map.m_pTeleLayer && (m_pEditor->m_Map.m_pTeleLayer->m_Width != NewW || m_pEditor->m_Map.m_pTeleLayer->m_Height != NewH))
|
||||
m_pEditor->m_Map.m_pTeleLayer->Resize(NewW, NewH);
|
||||
|
||||
// resize speedup layer if available
|
||||
if(m_Game && m_pEditor->m_Map.m_pSpeedupLayer && (m_pEditor->m_Map.m_pSpeedupLayer->m_Width != NewW || m_pEditor->m_Map.m_pSpeedupLayer->m_Height != NewH))
|
||||
m_pEditor->m_Map.m_pSpeedupLayer->Resize(NewW, NewH);
|
||||
|
||||
// resize front layer
|
||||
if(m_Game && m_pEditor->m_Map.m_pFrontLayer && (m_pEditor->m_Map.m_pFrontLayer->m_Width != NewW || m_pEditor->m_Map.m_pFrontLayer->m_Height != NewH))
|
||||
m_pEditor->m_Map.m_pFrontLayer->Resize(NewW, NewH);
|
||||
|
||||
// resize switch layer if available
|
||||
if(m_Game && m_pEditor->m_Map.m_pSwitchLayer && (m_pEditor->m_Map.m_pSwitchLayer->m_Width != NewW || m_pEditor->m_Map.m_pSwitchLayer->m_Height != NewH))
|
||||
m_pEditor->m_Map.m_pSwitchLayer->Resize(NewW, NewH);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -398,7 +287,7 @@ int CLayerTiles::RenderProperties(CUIRect *pToolBox)
|
|||
pToolBox->HSplitBottom(12.0f, pToolBox, &Button);
|
||||
|
||||
bool InGameGroup = !find_linear(m_pEditor->m_Map.m_pGameGroup->m_lLayers.all(), this).empty();
|
||||
if(m_pEditor->m_Map.m_pGameLayer == this || m_pEditor->m_Map.m_pTeleLayer == this || m_pEditor->m_Map.m_pSpeedupLayer == this || m_pEditor->m_Map.m_pFrontLayer == this || m_pEditor->m_Map.m_pSwitchLayer == this)
|
||||
if(m_pEditor->m_Map.m_pGameLayer == this)
|
||||
InGameGroup = false;
|
||||
static int s_ColclButton = 0;
|
||||
if(m_pEditor->DoButton_Editor(&s_ColclButton, Localize("Clear collision"), InGameGroup?0:-1, &Button, 0, Localize("Removes collision from this layer")))
|
||||
|
@ -449,7 +338,7 @@ int CLayerTiles::RenderProperties(CUIRect *pToolBox)
|
|||
{0},
|
||||
};
|
||||
|
||||
if(m_pEditor->m_Map.m_pGameLayer == this || m_pEditor->m_Map.m_pTeleLayer == this || m_pEditor->m_Map.m_pSpeedupLayer == this || m_pEditor->m_Map.m_pFrontLayer == this || m_pEditor->m_Map.m_pSwitchLayer == this) // remove the image from the selection if this is the game/tele/speedup/front/switch layer
|
||||
if(m_pEditor->m_Map.m_pGameLayer == this) // remove the image from the selection if this is the game layer
|
||||
aProps[2].m_pName = 0;
|
||||
|
||||
static int s_aIds[NUM_PROPS] = {0};
|
||||
|
@ -483,418 +372,3 @@ void CLayerTiles::ModifyImageIndex(INDEX_MODIFY_FUNC Func)
|
|||
void CLayerTiles::ModifyEnvelopeIndex(INDEX_MODIFY_FUNC Func)
|
||||
{
|
||||
}
|
||||
|
||||
CLayerTele::CLayerTele(int w, int h)
|
||||
: CLayerTiles(w, h)
|
||||
{
|
||||
m_pTypeName = "Tele";
|
||||
m_Tele = 1;
|
||||
|
||||
m_pTeleTile = new CTeleTile[w*h];
|
||||
mem_zero(m_pTeleTile, w*h*sizeof(CTeleTile));
|
||||
}
|
||||
|
||||
CLayerTele::~CLayerTele()
|
||||
{
|
||||
delete[] m_pTeleTile;
|
||||
}
|
||||
|
||||
void CLayerTele::Resize(int NewW, int NewH)
|
||||
{
|
||||
// resize tele data
|
||||
CTeleTile *pNewTeleData = new CTeleTile[NewW*NewH];
|
||||
mem_zero(pNewTeleData, NewW*NewH*sizeof(CTeleTile));
|
||||
|
||||
// copy old data
|
||||
for(int y = 0; y < min(NewH, m_Height); y++)
|
||||
mem_copy(&pNewTeleData[y*NewW], &m_pTeleTile[y*m_Width], min(m_Width, NewW)*sizeof(CTeleTile));
|
||||
|
||||
// replace old
|
||||
delete [] m_pTeleTile;
|
||||
m_pTeleTile = pNewTeleData;
|
||||
|
||||
// resize tile data
|
||||
CLayerTiles::Resize(NewW, NewH);
|
||||
|
||||
// resize gamelayer too
|
||||
if(m_pEditor->m_Map.m_pGameLayer->m_Width != NewW || m_pEditor->m_Map.m_pGameLayer->m_Height != NewH)
|
||||
m_pEditor->m_Map.m_pGameLayer->Resize(NewW, NewH);
|
||||
}
|
||||
|
||||
void CLayerTele::BrushDraw(CLayer *pBrush, float wx, float wy)
|
||||
{
|
||||
CLayerTele *l = (CLayerTele *)pBrush;
|
||||
int sx = ConvertX(wx);
|
||||
int sy = ConvertY(wy);
|
||||
|
||||
for(int y = 0; y < l->m_Height; y++)
|
||||
for(int x = 0; x < l->m_Width; x++)
|
||||
{
|
||||
int fx = x+sx;
|
||||
int fy = y+sy;
|
||||
if(fx<0 || fx >= m_Width || fy < 0 || fy >= m_Height)
|
||||
continue;
|
||||
|
||||
if(l->m_pTiles[y*l->m_Width+x].m_Index == TILE_TELEIN || l->m_pTiles[y*l->m_Width+x].m_Index == TILE_TELEINEVIL || l->m_pTiles[y*l->m_Width+x].m_Index == TILE_TELEOUT)
|
||||
{
|
||||
/*if(l->m_pTeleTile[y*l->m_Width+x].m_Number)
|
||||
m_pTeleTile[fy*m_Width+fx].m_Number = l->m_pTeleTile[y*l->m_Width+x].m_Number;
|
||||
else*/
|
||||
{
|
||||
if(!m_pEditor->m_TeleNum)
|
||||
{
|
||||
m_pTeleTile[fy*m_Width+fx].m_Number = 0;
|
||||
m_pTeleTile[fy*m_Width+fx].m_Type = 0;
|
||||
m_pTiles[fy*m_Width+fx].m_Index = 0;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
m_pTeleTile[fy*m_Width+fx].m_Number = m_pEditor->m_TeleNum;
|
||||
}
|
||||
|
||||
m_pTeleTile[fy*m_Width+fx].m_Type = l->m_pTiles[y*l->m_Width+x].m_Index;
|
||||
m_pTiles[fy*m_Width+fx].m_Index = l->m_pTiles[y*l->m_Width+x].m_Index;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pTeleTile[fy*m_Width+fx].m_Number = 0;
|
||||
m_pTeleTile[fy*m_Width+fx].m_Type = 0;
|
||||
m_pTiles[fy*m_Width+fx].m_Index = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CLayerTele::FillSelection(bool Empty, CLayer *pBrush, CUIRect Rect)
|
||||
{
|
||||
if(m_Readonly)
|
||||
return;
|
||||
|
||||
int sx = ConvertX(Rect.x);
|
||||
int sy = ConvertY(Rect.y);
|
||||
int w = ConvertX(Rect.w);
|
||||
int h = ConvertY(Rect.h);
|
||||
|
||||
CLayerTele *pLt = static_cast<CLayerTele*>(pBrush);
|
||||
|
||||
for(int y = 0; y <= h; y++)
|
||||
{
|
||||
for(int x = 0; x <= w; x++)
|
||||
{
|
||||
int fx = x+sx;
|
||||
int fy = y+sy;
|
||||
|
||||
if(fx < 0 || fx >= m_Width || fy < 0 || fy >= m_Height)
|
||||
continue;
|
||||
|
||||
if(Empty)
|
||||
{
|
||||
m_pTiles[fy*m_Width+fx].m_Index = 0;
|
||||
m_pTeleTile[fy*m_Width+fx].m_Number = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pTiles[fy*m_Width+fx] = pLt->m_pTiles[(y*pLt->m_Width + x%pLt->m_Width) % (pLt->m_Width*pLt->m_Height)];
|
||||
if(!pLt->m_pTeleTile[(y*pLt->m_Width + x%pLt->m_Width) % (pLt->m_Width*pLt->m_Height)].m_Number && m_pEditor->m_TeleNum && m_pTiles[fy*m_Width+fx].m_Index > 0)
|
||||
m_pTeleTile[fy*m_Width+fx].m_Number = m_pEditor->m_TeleNum;
|
||||
else
|
||||
m_pTeleTile[fy*m_Width+fx].m_Number = pLt->m_pTeleTile[(y*pLt->m_Width + x%pLt->m_Width) % (pLt->m_Width*pLt->m_Height)].m_Number;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CLayerSpeedup::CLayerSpeedup(int w, int h)
|
||||
: CLayerTiles(w, h)
|
||||
{
|
||||
m_pTypeName = "Speedup";
|
||||
m_Speedup = 1;
|
||||
|
||||
m_pSpeedupTile = new CSpeedupTile[w*h];
|
||||
mem_zero(m_pSpeedupTile, w*h*sizeof(CSpeedupTile));
|
||||
}
|
||||
|
||||
CLayerSpeedup::~CLayerSpeedup()
|
||||
{
|
||||
delete[] m_pSpeedupTile;
|
||||
}
|
||||
|
||||
void CLayerSpeedup::Resize(int NewW, int NewH)
|
||||
{
|
||||
// resize speedup data
|
||||
CSpeedupTile *pNewSpeedupData = new CSpeedupTile[NewW*NewH];
|
||||
mem_zero(pNewSpeedupData, NewW*NewH*sizeof(CSpeedupTile));
|
||||
|
||||
// copy old data
|
||||
for(int y = 0; y < min(NewH, m_Height); y++)
|
||||
mem_copy(&pNewSpeedupData[y*NewW], &m_pSpeedupTile[y*m_Width], min(m_Width, NewW)*sizeof(CSpeedupTile));
|
||||
|
||||
// replace old
|
||||
delete [] m_pSpeedupTile;
|
||||
m_pSpeedupTile = pNewSpeedupData;
|
||||
|
||||
// resize tile data
|
||||
CLayerTiles::Resize(NewW, NewH);
|
||||
|
||||
// resize gamelayer too
|
||||
if(m_pEditor->m_Map.m_pGameLayer->m_Width != NewW || m_pEditor->m_Map.m_pGameLayer->m_Height != NewH)
|
||||
m_pEditor->m_Map.m_pGameLayer->Resize(NewW, NewH);
|
||||
}
|
||||
|
||||
void CLayerSpeedup::BrushDraw(CLayer *pBrush, float wx, float wy)
|
||||
{
|
||||
CLayerSpeedup *l = (CLayerSpeedup *)pBrush;
|
||||
int sx = ConvertX(wx);
|
||||
int sy = ConvertY(wy);
|
||||
|
||||
for(int y = 0; y < l->m_Height; y++)
|
||||
for(int x = 0; x < l->m_Width; x++)
|
||||
{
|
||||
int fx = x+sx;
|
||||
int fy = y+sy;
|
||||
if(fx<0 || fx >= m_Width || fy < 0 || fy >= m_Height)
|
||||
continue;
|
||||
|
||||
if(l->m_pTiles[y*l->m_Width+x].m_Index == TILE_BOOST || l->m_pTiles[y*l->m_Width+x].m_Index == TILE_BOOSTS)
|
||||
{
|
||||
/*if(l->m_pSpeedupTile[y*l->m_Width+x].m_Force || l->m_pSpeedupTile[y*l->m_Width+x].m_Angle)
|
||||
{
|
||||
m_pSpeedupTile[fy*m_Width+fx].m_Force = l->m_pSpeedupTile[y*l->m_Width+x].m_Force;
|
||||
m_pSpeedupTile[fy*m_Width+fx].m_Angle = l->m_pSpeedupTile[y*l->m_Width+x].m_Angle;
|
||||
m_pSpeedupTile[fy*m_Width+fx].m_Type = l->m_pTiles[y*l->m_Width+x].m_Index;
|
||||
m_pTiles[fy*m_Width+fx].m_Index = l->m_pTiles[y*l->m_Width+x].m_Index;
|
||||
}
|
||||
else */
|
||||
if(m_pEditor->m_SpeedupForce)
|
||||
{
|
||||
m_pSpeedupTile[fy*m_Width+fx].m_Force = m_pEditor->m_SpeedupForce;
|
||||
m_pSpeedupTile[fy*m_Width+fx].m_MaxSpeed = m_pEditor->m_SpeedupMaxSpeed;
|
||||
m_pSpeedupTile[fy*m_Width+fx].m_Angle = m_pEditor->m_SpeedupAngle;
|
||||
m_pSpeedupTile[fy*m_Width+fx].m_Type = l->m_pTiles[y*l->m_Width+x].m_Index;
|
||||
m_pTiles[fy*m_Width+fx].m_Index = l->m_pTiles[y*l->m_Width+x].m_Index;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pSpeedupTile[fy*m_Width+fx].m_Force = 0;
|
||||
m_pSpeedupTile[fy*m_Width+fx].m_MaxSpeed = 0;
|
||||
m_pSpeedupTile[fy*m_Width+fx].m_Angle = 0;
|
||||
m_pTiles[fy*m_Width+fx].m_Index = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pSpeedupTile[fy*m_Width+fx].m_Force = 0;
|
||||
m_pSpeedupTile[fy*m_Width+fx].m_MaxSpeed = 0;
|
||||
m_pSpeedupTile[fy*m_Width+fx].m_Angle = 0;
|
||||
m_pTiles[fy*m_Width+fx].m_Index = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CLayerSpeedup::FillSelection(bool Empty, CLayer *pBrush, CUIRect Rect)
|
||||
{
|
||||
if(m_Readonly)
|
||||
return;
|
||||
|
||||
int sx = ConvertX(Rect.x);
|
||||
int sy = ConvertY(Rect.y);
|
||||
int w = ConvertX(Rect.w);
|
||||
int h = ConvertY(Rect.h);
|
||||
|
||||
CLayerSpeedup *pLt = static_cast<CLayerSpeedup*>(pBrush);
|
||||
|
||||
for(int y = 0; y <= h; y++)
|
||||
{
|
||||
for(int x = 0; x <= w; x++)
|
||||
{
|
||||
int fx = x+sx;
|
||||
int fy = y+sy;
|
||||
|
||||
if(fx < 0 || fx >= m_Width || fy < 0 || fy >= m_Height)
|
||||
continue;
|
||||
|
||||
if(Empty)
|
||||
{
|
||||
m_pTiles[fy*m_Width+fx].m_Index = 0;
|
||||
m_pSpeedupTile[fy*m_Width+fx].m_Force = 0;
|
||||
m_pSpeedupTile[fy*m_Width+fx].m_Angle = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pTiles[fy*m_Width+fx] = pLt->m_pTiles[(y*pLt->m_Width + x%pLt->m_Width) % (pLt->m_Width*pLt->m_Height)];
|
||||
if(!pLt->m_pSpeedupTile[(y*pLt->m_Width + x%pLt->m_Width) % (pLt->m_Width*pLt->m_Height)].m_Force && m_pEditor->m_SpeedupForce && m_pTiles[fy*m_Width+fx].m_Index > 0)
|
||||
{
|
||||
m_pSpeedupTile[fy*m_Width+fx].m_Force = m_pEditor->m_SpeedupForce;
|
||||
m_pSpeedupTile[fy*m_Width+fx].m_MaxSpeed = m_pEditor->m_SpeedupMaxSpeed;
|
||||
m_pSpeedupTile[fy*m_Width+fx].m_Angle = m_pEditor->m_SpeedupAngle;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pSpeedupTile[fy*m_Width+fx].m_Force = pLt->m_pSpeedupTile[(y*pLt->m_Width + x%pLt->m_Width) % (pLt->m_Width*pLt->m_Height)].m_Force;
|
||||
m_pSpeedupTile[fy*m_Width+fx].m_MaxSpeed = pLt->m_pSpeedupTile[(y*pLt->m_Width + x%pLt->m_Width) % (pLt->m_Width*pLt->m_Height)].m_MaxSpeed;
|
||||
m_pSpeedupTile[fy*m_Width+fx].m_Angle = pLt->m_pSpeedupTile[(y*pLt->m_Width + x%pLt->m_Width) % (pLt->m_Width*pLt->m_Height)].m_Angle;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CLayerFront::CLayerFront(int w, int h)
|
||||
: CLayerTiles(w, h)
|
||||
{
|
||||
m_pTypeName = "Front";
|
||||
m_Front = 1;
|
||||
}
|
||||
|
||||
void CLayerFront::Resize(int NewW, int NewH)
|
||||
{
|
||||
// resize tile data
|
||||
CLayerTiles::Resize(NewW, NewH);
|
||||
|
||||
// resize gamelayer too
|
||||
if(m_pEditor->m_Map.m_pGameLayer->m_Width != NewW || m_pEditor->m_Map.m_pGameLayer->m_Height != NewH)
|
||||
m_pEditor->m_Map.m_pGameLayer->Resize(NewW, NewH);
|
||||
}
|
||||
|
||||
void CLayerFront::BrushDraw(CLayer *pBrush, float wx, float wy)
|
||||
{
|
||||
if(m_Readonly)
|
||||
return;
|
||||
|
||||
//
|
||||
CLayerTiles *l = (CLayerTiles *)pBrush;
|
||||
int sx = ConvertX(wx);
|
||||
int sy = ConvertY(wy);
|
||||
|
||||
for(int y = 0; y < l->m_Height; y++)
|
||||
for(int x = 0; x < l->m_Width; x++)
|
||||
{
|
||||
int fx = x+sx;
|
||||
int fy = y+sy;
|
||||
if(fx<0 || fx >= m_Width || fy < 0 || fy >= m_Height)
|
||||
continue;
|
||||
|
||||
// dont allow tele in and out tiles... same with speedup tile and alot more in front
|
||||
if(m_pEditor->GetSelectedLayer(0) == m_pEditor->m_Map.m_pFrontLayer && (l->m_pTiles[y*l->m_Width+x].m_Index == TILE_TELEIN || l->m_pTiles[y*l->m_Width+x].m_Index == TILE_TELEINEVIL || l->m_pTiles[y*l->m_Width+x].m_Index == TILE_TELEOUT || l->m_pTiles[y*l->m_Width+x].m_Index == TILE_BOOST || l->m_pTiles[y*l->m_Width+x].m_Index == TILE_BOOSTS || l->m_pTiles[y*l->m_Width+x].m_Index == TILE_BOOSTS || l->m_pTiles[y*l->m_Width+x].m_Index == (ENTITY_TRIGGER + ENTITY_OFFSET) || l->m_pTiles[y*l->m_Width+x].m_Index == (ENTITY_DOOR + ENTITY_OFFSET)) || l->m_pTiles[y*l->m_Width+x].m_Index == (TILE_SOLID) || l->m_pTiles[y*l->m_Width+x].m_Index == (TILE_NOHOOK) || (l->m_pTiles[y*l->m_Width+x].m_Index >=TILE_CP_D && l->m_pTiles[y*l->m_Width+x].m_Index <=TILE_CP_L_F))
|
||||
continue;
|
||||
m_pTiles[fy*m_Width+fx] = l->m_pTiles[y*l->m_Width+x];
|
||||
}
|
||||
}
|
||||
|
||||
CLayerSwitch::CLayerSwitch(int w, int h)
|
||||
: CLayerTiles(w, h)
|
||||
{
|
||||
m_pTypeName = "Switch";
|
||||
m_Switch = 1;
|
||||
|
||||
m_pSwitchTile = new CTeleTile[w*h];
|
||||
mem_zero(m_pSwitchTile, w*h*sizeof(CTeleTile));
|
||||
}
|
||||
|
||||
CLayerSwitch::~CLayerSwitch()
|
||||
{
|
||||
delete[] m_pSwitchTile;
|
||||
}
|
||||
|
||||
void CLayerSwitch::Resize(int NewW, int NewH)
|
||||
{
|
||||
// resize switch data
|
||||
CTeleTile *pNewSwitchData = new CTeleTile[NewW*NewH];
|
||||
mem_zero(pNewSwitchData, NewW*NewH*sizeof(CTeleTile));
|
||||
|
||||
// copy old data
|
||||
for(int y = 0; y < min(NewH, m_Height); y++)
|
||||
mem_copy(&pNewSwitchData[y*NewW], &m_pSwitchTile[y*m_Width], min(m_Width, NewW)*sizeof(CTeleTile));
|
||||
|
||||
// replace old
|
||||
delete [] m_pSwitchTile;
|
||||
m_pSwitchTile = pNewSwitchData;
|
||||
|
||||
// resize tile data
|
||||
CLayerTiles::Resize(NewW, NewH);
|
||||
|
||||
// resize gamelayer too
|
||||
if(m_pEditor->m_Map.m_pGameLayer->m_Width != NewW || m_pEditor->m_Map.m_pGameLayer->m_Height != NewH)
|
||||
m_pEditor->m_Map.m_pGameLayer->Resize(NewW, NewH);
|
||||
}
|
||||
|
||||
void CLayerSwitch::BrushDraw(CLayer *pBrush, float wx, float wy)
|
||||
{
|
||||
CLayerSwitch *l = (CLayerSwitch *)pBrush;
|
||||
int sx = ConvertX(wx);
|
||||
int sy = ConvertY(wy);
|
||||
|
||||
for(int y = 0; y < l->m_Height; y++)
|
||||
for(int x = 0; x < l->m_Width; x++)
|
||||
{
|
||||
int fx = x+sx;
|
||||
int fy = y+sy;
|
||||
if(fx<0 || fx >= m_Width || fy < 0 || fy >= m_Height)
|
||||
continue;
|
||||
|
||||
if(l->m_pTiles[y*l->m_Width+x].m_Index == (ENTITY_DOOR + ENTITY_OFFSET) || l->m_pTiles[y*l->m_Width+x].m_Index == (ENTITY_TRIGGER + ENTITY_OFFSET) || l->m_pTiles[y*l->m_Width+x].m_Index == (ENTITY_LASER_LONG + ENTITY_OFFSET) || l->m_pTiles[y*l->m_Width+x].m_Index == (ENTITY_LASER_MIDDLE + ENTITY_OFFSET) || l->m_pTiles[y*l->m_Width+x].m_Index == (ENTITY_LASER_SHORT + ENTITY_OFFSET))
|
||||
{
|
||||
/*if(l->m_pSwitchTile[y*l->m_Width+x].m_Number)
|
||||
m_pSwitchTile[fy*m_Width+fx].m_Number = l->m_pSwitchTile[y*l->m_Width+x].m_Number;
|
||||
else*/
|
||||
{
|
||||
if(!m_pEditor->m_SwitchNum)
|
||||
{
|
||||
m_pSwitchTile[fy*m_Width+fx].m_Number = 0;
|
||||
m_pSwitchTile[fy*m_Width+fx].m_Type = 0;
|
||||
m_pTiles[fy*m_Width+fx].m_Index = 0;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
m_pSwitchTile[fy*m_Width+fx].m_Number = m_pEditor->m_SwitchNum;
|
||||
}
|
||||
|
||||
m_pSwitchTile[fy*m_Width+fx].m_Type = l->m_pTiles[y*l->m_Width+x].m_Index;
|
||||
m_pTiles[fy*m_Width+fx].m_Index = l->m_pTiles[y*l->m_Width+x].m_Index;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pSwitchTile[fy*m_Width+fx].m_Number = 0;
|
||||
m_pSwitchTile[fy*m_Width+fx].m_Type = 0;
|
||||
m_pTiles[fy*m_Width+fx].m_Index = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CLayerSwitch::FillSelection(bool Empty, CLayer *pBrush, CUIRect Rect)
|
||||
{
|
||||
if(m_Readonly)
|
||||
return;
|
||||
|
||||
int sx = ConvertX(Rect.x);
|
||||
int sy = ConvertY(Rect.y);
|
||||
int w = ConvertX(Rect.w);
|
||||
int h = ConvertY(Rect.h);
|
||||
|
||||
CLayerSwitch *pLt = static_cast<CLayerSwitch*>(pBrush);
|
||||
|
||||
for(int y = 0; y <= h; y++)
|
||||
{
|
||||
for(int x = 0; x <= w; x++)
|
||||
{
|
||||
int fx = x+sx;
|
||||
int fy = y+sy;
|
||||
|
||||
if(fx < 0 || fx >= m_Width || fy < 0 || fy >= m_Height)
|
||||
continue;
|
||||
|
||||
if(Empty)
|
||||
{
|
||||
m_pTiles[fy*m_Width+fx].m_Index = 0;
|
||||
m_pSwitchTile[fy*m_Width+fx].m_Number = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pTiles[fy*m_Width+fx] = pLt->m_pTiles[(y*pLt->m_Width + x%pLt->m_Width) % (pLt->m_Width*pLt->m_Height)];
|
||||
if(!pLt->m_pSwitchTile[(y*pLt->m_Width + x%pLt->m_Width) % (pLt->m_Width*pLt->m_Height)].m_Number && m_pEditor->m_SwitchNum && m_pTiles[fy*m_Width+fx].m_Index > 0)
|
||||
m_pSwitchTile[fy*m_Width+fx].m_Number = m_pEditor->m_SwitchNum;
|
||||
else
|
||||
m_pSwitchTile[fy*m_Width+fx].m_Number = pLt->m_pSwitchTile[(y*pLt->m_Width + x%pLt->m_Width) % (pLt->m_Width*pLt->m_Height)].m_Number;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -93,81 +93,11 @@ int CEditor::PopupGroup(CEditor *pEditor, CUIRect View)
|
|||
return 1;
|
||||
}
|
||||
|
||||
if(pEditor->GetSelectedGroup()->m_GameGroup && !pEditor->m_Map.m_pTeleLayer)
|
||||
{
|
||||
// new tele layer
|
||||
View.HSplitBottom(10.0f, &View, &Button);
|
||||
View.HSplitBottom(12.0f, &View, &Button);
|
||||
static int s_NewSwitchLayerButton = 0;
|
||||
if(pEditor->DoButton_Editor(&s_NewSwitchLayerButton, "Add Tele Layer", 0, &Button, 0, "Creates a new tele layer"))
|
||||
{
|
||||
CLayer *l = new CLayerTele(pEditor->m_Map.m_pGameLayer->m_Width, pEditor->m_Map.m_pGameLayer->m_Height);
|
||||
pEditor->m_Map.MakeTeleLayer(l);
|
||||
pEditor->m_Map.m_lGroups[pEditor->m_SelectedGroup]->AddLayer(l);
|
||||
pEditor->m_SelectedLayer = pEditor->m_Map.m_lGroups[pEditor->m_SelectedGroup]->m_lLayers.size()-1;
|
||||
pEditor->m_Brush.Clear();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if(pEditor->GetSelectedGroup()->m_GameGroup && !pEditor->m_Map.m_pSpeedupLayer)
|
||||
{
|
||||
// new speedup layer
|
||||
View.HSplitBottom(10.0f, &View, &Button);
|
||||
View.HSplitBottom(12.0f, &View, &Button);
|
||||
static int s_NewSwitchLayerButton = 0;
|
||||
if(pEditor->DoButton_Editor(&s_NewSwitchLayerButton, "Add Speedup Layer", 0, &Button, 0, "Creates a new speedup layer"))
|
||||
{
|
||||
CLayer *l = new CLayerSpeedup(pEditor->m_Map.m_pGameLayer->m_Width, pEditor->m_Map.m_pGameLayer->m_Height);
|
||||
pEditor->m_Map.MakeSpeedupLayer(l);
|
||||
pEditor->m_Map.m_lGroups[pEditor->m_SelectedGroup]->AddLayer(l);
|
||||
pEditor->m_SelectedLayer = pEditor->m_Map.m_lGroups[pEditor->m_SelectedGroup]->m_lLayers.size()-1;
|
||||
pEditor->m_Brush.Clear();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if(pEditor->GetSelectedGroup()->m_GameGroup && !pEditor->m_Map.m_pFrontLayer)
|
||||
{
|
||||
// new force layer
|
||||
View.HSplitBottom(10.0f, &View, &Button);
|
||||
View.HSplitBottom(12.0f, &View, &Button);
|
||||
static int s_NewFrontLayerButton = 0;
|
||||
if(pEditor->DoButton_Editor(&s_NewFrontLayerButton, "Add Front Layer", 0, &Button, 0, "Creates a new item layer"))
|
||||
{
|
||||
CLayer *l = new CLayerFront(pEditor->m_Map.m_pGameLayer->m_Width, pEditor->m_Map.m_pGameLayer->m_Height);
|
||||
pEditor->m_Map.MakeFrontLayer(l);
|
||||
pEditor->m_Map.m_lGroups[pEditor->m_SelectedGroup]->AddLayer(l);
|
||||
pEditor->m_SelectedLayer = pEditor->m_Map.m_lGroups[pEditor->m_SelectedGroup]->m_lLayers.size()-1;
|
||||
pEditor->m_Brush.Clear();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if(pEditor->GetSelectedGroup()->m_GameGroup && !pEditor->m_Map.m_pSwitchLayer)
|
||||
{
|
||||
// new Switch layer
|
||||
View.HSplitBottom(10.0f, &View, &Button);
|
||||
View.HSplitBottom(12.0f, &View, &Button);
|
||||
static int s_NewSwitchLayerButton = 0;
|
||||
if(pEditor->DoButton_Editor(&s_NewSwitchLayerButton, "Add Switch Layer", 0, &Button, 0, "Creates a new switch layer"))
|
||||
{
|
||||
CLayer *l = new CLayerSwitch(pEditor->m_Map.m_pGameLayer->m_Width, pEditor->m_Map.m_pGameLayer->m_Height);
|
||||
pEditor->m_Map.MakeSwitchLayer(l);
|
||||
pEditor->m_Map.m_lGroups[pEditor->m_SelectedGroup]->AddLayer(l);
|
||||
pEditor->m_SelectedLayer = pEditor->m_Map.m_lGroups[pEditor->m_SelectedGroup]->m_lLayers.size()-1;
|
||||
pEditor->m_Brush.Clear();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// new tile layer
|
||||
View.HSplitBottom(10.0f, &View, &Button);
|
||||
View.HSplitBottom(12.0f, &View, &Button);
|
||||
static int s_NewQuadLayerButton = 0;
|
||||
//if(pEditor->DoButton_Editor(&s_NewQuadLayerButton, Localize("Add quads layer"), 0, &Button, 0, Localize("Creates a new quad layer")))
|
||||
if(pEditor->DoButton_Editor(&s_NewQuadLayerButton, Localize("Add Quads Layer"), 0, &Button, 0, Localize("Creates a new quad layer")))
|
||||
if(pEditor->DoButton_Editor(&s_NewQuadLayerButton, Localize("Add quads layer"), 0, &Button, 0, Localize("Creates a new quad layer")))
|
||||
{
|
||||
CLayer *l = new CLayerQuads;
|
||||
l->m_pEditor = pEditor;
|
||||
|
@ -180,10 +110,9 @@ int CEditor::PopupGroup(CEditor *pEditor, CUIRect View)
|
|||
View.HSplitBottom(5.0f, &View, &Button);
|
||||
View.HSplitBottom(12.0f, &View, &Button);
|
||||
static int s_NewTileLayerButton = 0;
|
||||
//if(pEditor->DoButton_Editor(&s_NewTileLayerButton, Localize("Add tile layer"), 0, &Button, 0, Localize("Creates a new tile layer")))
|
||||
if(pEditor->DoButton_Editor(&s_NewTileLayerButton, Localize("Add Tile Layer"), 0, &Button, 0, Localize("Creates a new tile layer")))
|
||||
if(pEditor->DoButton_Editor(&s_NewTileLayerButton, Localize("Add tile layer"), 0, &Button, 0, Localize("Creates a new tile layer")))
|
||||
{
|
||||
CLayer *l = new CLayerTiles(pEditor->m_Map.m_pGameLayer->m_Width, pEditor->m_Map.m_pGameLayer->m_Height);
|
||||
CLayer *l = new CLayerTiles(50, 50);
|
||||
l->m_pEditor = pEditor;
|
||||
pEditor->m_Map.m_lGroups[pEditor->m_SelectedGroup]->AddLayer(l);
|
||||
pEditor->m_SelectedLayer = pEditor->m_Map.m_lGroups[pEditor->m_SelectedGroup]->m_lLayers.size()-1;
|
||||
|
@ -255,16 +184,10 @@ int CEditor::PopupLayer(CEditor *pEditor, CUIRect View)
|
|||
View.HSplitBottom(12.0f, &View, &Button);
|
||||
static int s_DeleteButton = 0;
|
||||
|
||||
// don't allow deletion of game/front layer
|
||||
if(pEditor->m_Map.m_pGameLayer != pEditor->GetSelectedLayer(0) && pEditor->m_Map.m_pFrontLayer != pEditor->GetSelectedLayer(0) &&
|
||||
// don't allow deletion of game layer
|
||||
if(pEditor->m_Map.m_pGameLayer != pEditor->GetSelectedLayer(0) &&
|
||||
pEditor->DoButton_Editor(&s_DeleteButton, Localize("Delete layer"), 0, &Button, 0, Localize("Deletes the layer")))
|
||||
{
|
||||
if(pEditor->GetSelectedLayer(0) == pEditor->m_Map.m_pTeleLayer)
|
||||
pEditor->m_Map.m_pTeleLayer = 0x0;
|
||||
if(pEditor->GetSelectedLayer(0) == pEditor->m_Map.m_pSpeedupLayer)
|
||||
pEditor->m_Map.m_pSpeedupLayer = 0x0;
|
||||
if(pEditor->GetSelectedLayer(0) == pEditor->m_Map.m_pSwitchLayer)
|
||||
pEditor->m_Map.m_pSwitchLayer = 0x0;
|
||||
pEditor->m_Map.m_lGroups[pEditor->m_SelectedGroup]->DeleteLayer(pEditor->m_SelectedLayer);
|
||||
return 1;
|
||||
}
|
||||
|
@ -289,11 +212,11 @@ int CEditor::PopupLayer(CEditor *pEditor, CUIRect View)
|
|||
{0},
|
||||
};
|
||||
|
||||
if(pEditor->m_Map.m_pGameLayer == pEditor->GetSelectedLayer(0) || pEditor->m_Map.m_pTeleLayer == pEditor->GetSelectedLayer(0) || pEditor->m_Map.m_pSpeedupLayer == pEditor->GetSelectedLayer(0) || pEditor->m_Map.m_pFrontLayer == pEditor->GetSelectedLayer(0) || pEditor->m_Map.m_pSwitchLayer == pEditor->GetSelectedLayer(0)) // dont use Group and Detail from the selection if this is the game layer
|
||||
if(pEditor->m_Map.m_pGameLayer == pEditor->GetSelectedLayer(0)) // dont use Group and Detail from the selection if this is the game layer
|
||||
{
|
||||
aProps[0].m_Type = PROPTYPE_NULL;
|
||||
aProps[2].m_Type = PROPTYPE_NULL;
|
||||
}
|
||||
aProps[2].m_Type = PROPTYPE_NULL;
|
||||
}
|
||||
|
||||
static int s_aIds[NUM_PROPS] = {0};
|
||||
int NewVal = 0;
|
||||
|
@ -545,88 +468,7 @@ int CEditor::PopupSelectImageResult()
|
|||
return g_SelectImageCurrent;
|
||||
}
|
||||
|
||||
int CEditor::PopupTele(CEditor *pEditor, CUIRect View)
|
||||
{
|
||||
CUIRect Button;
|
||||
View.HSplitBottom(12.0f, &View, &Button);
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_TELE=0,
|
||||
NUM_PROPS,
|
||||
};
|
||||
|
||||
CProperty aProps[] = {
|
||||
{"Number", pEditor->m_TeleNum, PROPTYPE_INT_STEP, 0, 255},
|
||||
{0},
|
||||
};
|
||||
|
||||
static int s_aIds[NUM_PROPS] = {0};
|
||||
int NewVal = 0;
|
||||
int Prop = pEditor->DoProperties(&View, aProps, s_aIds, &NewVal);
|
||||
|
||||
if(Prop == PROP_TELE)
|
||||
pEditor->m_TeleNum = clamp(NewVal, 0, 255);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CEditor::PopupSpeedup(CEditor *pEditor, CUIRect View)
|
||||
{
|
||||
CUIRect Button;
|
||||
View.HSplitBottom(12.0f, &View, &Button);
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_FORCE=0,
|
||||
PROP_MAXSPEED,
|
||||
PROP_ANGLE,
|
||||
NUM_PROPS
|
||||
};
|
||||
|
||||
CProperty aProps[] = {
|
||||
{"Force", pEditor->m_SpeedupForce, PROPTYPE_INT_SCROLL, 0, 255},
|
||||
{"Max Speed", pEditor->m_SpeedupMaxSpeed, PROPTYPE_INT_SCROLL, 0, 255},
|
||||
{"Angle", pEditor->m_SpeedupAngle, PROPTYPE_INT_SCROLL, 0, 359},
|
||||
{0},
|
||||
};
|
||||
|
||||
static int s_aIds[NUM_PROPS] = {0};
|
||||
int NewVal = 0;
|
||||
int Prop = pEditor->DoProperties(&View, aProps, s_aIds, &NewVal);
|
||||
|
||||
if(Prop == PROP_FORCE)
|
||||
pEditor->m_SpeedupForce = clamp(NewVal, 0, 255);
|
||||
if(Prop == PROP_MAXSPEED)
|
||||
pEditor->m_SpeedupMaxSpeed = clamp(NewVal, 0, 255);
|
||||
if(Prop == PROP_ANGLE)
|
||||
pEditor->m_SpeedupAngle = clamp(NewVal, 0, 359);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CEditor::PopupSwitch(CEditor *pEditor, CUIRect View)
|
||||
{
|
||||
CUIRect Button;
|
||||
View.HSplitBottom(12.0f, &View, &Button);
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_Switch=0,
|
||||
NUM_PROPS,
|
||||
};
|
||||
|
||||
CProperty aProps[] = {
|
||||
{"Number", pEditor->m_SwitchNum, PROPTYPE_INT_STEP, 0, 255},
|
||||
{0},
|
||||
};
|
||||
|
||||
static int s_aIds[NUM_PROPS] = {0};
|
||||
int NewVal = 0;
|
||||
int Prop = pEditor->DoProperties(&View, aProps, s_aIds, &NewVal);
|
||||
|
||||
if(Prop == PROP_Switch)
|
||||
pEditor->m_SwitchNum = clamp(NewVal, 0, 255);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -21,14 +21,14 @@ class CLayers
|
|||
public:
|
||||
CLayers();
|
||||
void Init(class IKernel *pKernel);
|
||||
int NumGroups() const { return m_GroupsNum; }
|
||||
class IMap *Map() const { return m_pMap; }
|
||||
CMapItemGroup *GameGroup() const { return m_pGameGroup; }
|
||||
CMapItemLayerTilemap *GameLayer() const { return m_pGameLayer; }
|
||||
CMapItemLayerTilemap *TeleLayer() const { return m_pTeleLayer; }
|
||||
CMapItemLayerTilemap *SpeedupLayer() const { return m_pSpeedupLayer; }
|
||||
CMapItemLayerTilemap *FrontLayer() const { return m_pFrontLayer; }
|
||||
CMapItemLayerTilemap *SwitchLayer() const { return m_pSwitchLayer; }
|
||||
int NumGroups() const { return m_GroupsNum; };
|
||||
class IMap *Map() const { return m_pMap; };
|
||||
CMapItemGroup *GameGroup() const { return m_pGameGroup; };
|
||||
CMapItemLayerTilemap *GameLayer() const { return m_pGameLayer; };
|
||||
CMapItemLayerTilemap *TeleLayer() const { return m_pTeleLayer; };
|
||||
CMapItemLayerTilemap *SpeedupLayer() const { return m_pSpeedupLayer; };
|
||||
CMapItemLayerTilemap *FrontLayer() const { return m_pFrontLayer; };
|
||||
CMapItemLayerTilemap *SwitchLayer() const { return m_pSwitchLayer; };
|
||||
CMapItemGroup *GetGroup(int Index) const;
|
||||
CMapItemLayer *GetLayer(int Index) const;
|
||||
};
|
||||
|
|
|
@ -140,16 +140,6 @@ enum
|
|||
ENTITY_OFFSET=255-16*4,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
LAYER_GAME,
|
||||
LAYER_FRONT,
|
||||
LAYER_LASER,
|
||||
LAYER_TELE,
|
||||
LAYER_SPEEDUP,
|
||||
NUM_LAYERS
|
||||
};
|
||||
|
||||
struct CPoint
|
||||
{
|
||||
int x, y; // 22.10 fixed point
|
||||
|
|
|
@ -624,25 +624,6 @@ void CCharacter::OnFinish()
|
|||
if(!GameServer()->Score()->PlayerData(m_pPlayer->GetCID())->m_CurrentTime || GameServer()->Score()->PlayerData(m_pPlayer->GetCID())->m_CurrentTime > time)
|
||||
{
|
||||
GameServer()->Score()->PlayerData(m_pPlayer->GetCID())->m_CurrentTime = time;
|
||||
|
||||
// send it to all players
|
||||
for(int i = 0; i < MAX_CLIENTS; i++)
|
||||
{
|
||||
if(GameServer()->m_apPlayers[i] && GameServer()->m_apPlayers[i]->m_IsUsingRaceClient)
|
||||
{
|
||||
if(g_Config.m_SvHideScore || i == m_pPlayer->GetCID())
|
||||
{
|
||||
CNetMsg_Sv_PlayerTime Msg;
|
||||
char aBuf[16];
|
||||
str_format(aBuf, sizeof(aBuf), "%.0f", time*100.0f); // damn ugly but the only way i know to do it
|
||||
int TimeToSend;
|
||||
sscanf(aBuf, "%d", &TimeToSend);
|
||||
Msg.m_Time = TimeToSend;
|
||||
Msg.m_Cid = m_pPlayer->GetCID();
|
||||
Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int TTime = 0-(int)time;
|
||||
|
@ -724,49 +705,29 @@ void CCharacter::Tick()
|
|||
{
|
||||
if (m_RaceState == RACE_STARTED) {
|
||||
int IntTime = (int)time;
|
||||
if(m_pPlayer->m_IsUsingRaceClient)
|
||||
{
|
||||
CNetMsg_Sv_RaceTime Msg;
|
||||
Msg.m_Time = IntTime;
|
||||
Msg.m_Check = 0;
|
||||
|
||||
if(m_CpActive != -1 && m_CpTick > Server()->Tick())
|
||||
{
|
||||
if(pData->m_BestTime && pData->m_aBestCpTime[m_CpActive] != 0)
|
||||
{
|
||||
float Diff = (m_CpCurrent[m_CpActive] - pData->m_aBestCpTime[m_CpActive])*100;
|
||||
Msg.m_Check = (int)Diff;
|
||||
}
|
||||
}
|
||||
|
||||
Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, m_pPlayer->GetCID());
|
||||
}
|
||||
if(m_BroadTime)
|
||||
str_format(aBuftime, sizeof(aBuftime), "%dm %ds", IntTime/60, IntTime%60);
|
||||
else
|
||||
str_format(aBuftime, sizeof(aBuftime), "");
|
||||
|
||||
if(m_CpActive != -1 && m_CpTick > Server()->Tick())
|
||||
{
|
||||
if(m_BroadTime)
|
||||
str_format(aBuftime, sizeof(aBuftime), "%dm %ds", IntTime/60, IntTime%60);
|
||||
else
|
||||
str_format(aBuftime, sizeof(aBuftime), "");
|
||||
|
||||
if(m_CpActive != -1 && m_CpTick > Server()->Tick())
|
||||
{
|
||||
if(pData->m_BestTime && pData->m_aBestCpTime[m_CpActive] != 0)
|
||||
{
|
||||
char aTmp[128];
|
||||
float Diff = m_CpCurrent[m_CpActive] - pData->m_aBestCpTime[m_CpActive];
|
||||
str_format(aTmp, sizeof(aTmp), "\nCheckpoint | Diff : %+5.2f", Diff);
|
||||
strcat(aBuftime, aTmp);
|
||||
}
|
||||
}
|
||||
|
||||
if( g_Config.m_SvBroadcast[0] != 0 && m_BroadCast)
|
||||
if(pData->m_BestTime && pData->m_aBestCpTime[m_CpActive] != 0)
|
||||
{
|
||||
char aTmp[128];
|
||||
str_format(aTmp, sizeof(aTmp), "\n%s\n", g_Config.m_SvBroadcast);
|
||||
float Diff = m_CpCurrent[m_CpActive] - pData->m_aBestCpTime[m_CpActive];
|
||||
str_format(aTmp, sizeof(aTmp), "\nCheckpoint | Diff : %+5.2f", Diff);
|
||||
strcat(aBuftime, aTmp);
|
||||
}
|
||||
GameServer()->SendBroadcast(aBuftime, m_pPlayer->GetCID());
|
||||
}
|
||||
|
||||
if( g_Config.m_SvBroadcast[0] != 0 && m_BroadCast)
|
||||
{
|
||||
char aTmp[128];
|
||||
str_format(aTmp, sizeof(aTmp), "\n%s\n", g_Config.m_SvBroadcast);
|
||||
strcat(aBuftime, aTmp);
|
||||
}
|
||||
GameServer()->SendBroadcast(aBuftime, m_pPlayer->GetCID());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1303,7 +1264,7 @@ void CCharacter::Snap(int SnappingClient)
|
|||
|
||||
CCharacter* SnapChar = GameServer()->GetPlayerChar(SnappingClient);
|
||||
if(!SnapChar
|
||||
|| (!SnapChar->GetPlayer()->m_ShowOthers && SnapChar->Team() != Team())
|
||||
|| (SnapChar->Team() != Team())
|
||||
|| (GetPlayer()->m_Invisible && GetPlayer()->GetCID() != SnappingClient)) return;
|
||||
CNetObj_Character *Character = static_cast<CNetObj_Character *>(Server()->SnapNewItem(NETOBJTYPE_CHARACTER, m_pPlayer->GetCID(), sizeof(CNetObj_Character)));
|
||||
|
||||
|
|
|
@ -117,9 +117,7 @@ void CDragger::Snap(int SnappingClient)
|
|||
return;
|
||||
|
||||
CCharacter * Char = GameServer()->GetPlayerChar(SnappingClient);
|
||||
if(Char && m_Target
|
||||
&& !Char->GetPlayer()->m_ShowOthers
|
||||
&& Char->Team() != m_Target->Team()) return;
|
||||
if(Char && m_Target && Char->Team() != m_Target->Team()) return;
|
||||
|
||||
CNetObj_Laser *obj = static_cast<CNetObj_Laser *>(Server()->SnapNewItem(NETOBJTYPE_LASER, m_Id, sizeof(CNetObj_Laser)));
|
||||
|
||||
|
|
|
@ -117,8 +117,7 @@ void CLaser::Snap(int SnappingClient)
|
|||
if(NetworkClipped(SnappingClient))
|
||||
return;
|
||||
CCharacter * Char = GameServer()->GetPlayerChar(SnappingClient);
|
||||
if(Char && m_Owner != -1 && !Char->GetPlayer()->m_ShowOthers &&
|
||||
Char->Team() != GameServer()->GetPlayerChar(m_Owner)->Team()) return;
|
||||
if(Char && m_Owner != -1 && Char->Team() != GameServer()->GetPlayerChar(m_Owner)->Team()) return;
|
||||
CNetObj_Laser *pObj = static_cast<CNetObj_Laser *>(Server()->SnapNewItem(NETOBJTYPE_LASER, m_Id, sizeof(CNetObj_Laser)));
|
||||
pObj->m_X = (int)m_Pos.x;
|
||||
pObj->m_Y = (int)m_Pos.y;
|
||||
|
|
|
@ -82,7 +82,7 @@ void CPlasma::Snap(int SnappingClient)
|
|||
if(NetworkClipped(SnappingClient))
|
||||
return;
|
||||
CCharacter* SnapChar = GameServer()->GetPlayerChar(SnappingClient);
|
||||
if(!SnapChar || (!SnapChar->GetPlayer()->m_ShowOthers && SnapChar->Team() != m_ResponsibleTeam)) return;
|
||||
if(!SnapChar || (SnapChar->Team() != m_ResponsibleTeam)) return;
|
||||
CNetObj_Laser *pObj = static_cast<CNetObj_Laser *>(Server()->SnapNewItem(NETOBJTYPE_LASER, m_Id, sizeof(CNetObj_Laser)));
|
||||
pObj->m_X = (int)m_Pos.x;
|
||||
pObj->m_Y = (int)m_Pos.y;
|
||||
|
|
|
@ -158,8 +158,7 @@ void CProjectile::Snap(int SnappingClient)
|
|||
if(NetworkClipped(SnappingClient, GetPos(Ct)))
|
||||
return;
|
||||
CCharacter * Char = GameServer()->GetPlayerChar(SnappingClient);
|
||||
if(Char && m_Owner != -1 && !Char->GetPlayer()->m_ShowOthers &&
|
||||
Char->CanCollide(m_Owner)) return;
|
||||
if(Char && m_Owner != -1 && Char->CanCollide(m_Owner)) return;
|
||||
CNetObj_Projectile *pProj = static_cast<CNetObj_Projectile *>(Server()->SnapNewItem(NETOBJTYPE_PROJECTILE, m_Id, sizeof(CNetObj_Projectile)));
|
||||
FillInfo(pProj);
|
||||
}
|
||||
|
|
|
@ -885,19 +885,6 @@ void CGameContext::OnMessage(int MsgId, CUnpacker *pUnpacker, int ClientId)
|
|||
mem_zero(aMsg,sizeof(aMsg));
|
||||
}
|
||||
}
|
||||
/* disable it for vanilla clients
|
||||
else if(!str_comp(pMsg->m_pMessage, "/show_others"))
|
||||
{
|
||||
if(!g_Config.m_SvShowOthers && !Server()->IsAuthed(ClientId))
|
||||
{
|
||||
SendChatTarget(ClientId, "This command is not allowed on this server.");
|
||||
return;
|
||||
}
|
||||
if(pPlayer->m_IsUsingRaceClient)
|
||||
SendChatTarget(ClientId, "Please use the settings to switch this option.");
|
||||
else
|
||||
pPlayer->m_ShowOthers = !pPlayer->m_ShowOthers;
|
||||
}*/
|
||||
else if (!str_comp_nocase(pMsg->m_pMessage, "/time") && g_Config.m_SvEmotionalTees)
|
||||
|
||||
{
|
||||
|
@ -1066,42 +1053,6 @@ void CGameContext::OnMessage(int MsgId, CUnpacker *pUnpacker, int ClientId)
|
|||
}
|
||||
|
||||
|
||||
}
|
||||
else if(MsgId == NETMSGTYPE_CL_ISRACE)
|
||||
{
|
||||
pPlayer->m_IsUsingRaceClient = true;
|
||||
pPlayer->m_ShowOthers = true;
|
||||
pPlayer->m_ShowOthers = true;
|
||||
((CGameControllerDDRace*)m_pController)->m_Teams.SendAllInfo(pPlayer->GetCID());
|
||||
// send time of all players
|
||||
for(int i = 0; i < MAX_CLIENTS; i++)
|
||||
{
|
||||
if(m_apPlayers[i] && Score()->PlayerData(i)->m_CurrentTime > 0)
|
||||
{
|
||||
char aBuf[16];
|
||||
str_format(aBuf, sizeof(aBuf), "%.0f", Score()->PlayerData(i)->m_CurrentTime*100.0f); // damn ugly but the only way i know to do it
|
||||
int TimeToSend;
|
||||
sscanf(aBuf, "%d", &TimeToSend);
|
||||
CNetMsg_Sv_PlayerTime Msg;
|
||||
Msg.m_Time = TimeToSend;
|
||||
Msg.m_Cid = i;
|
||||
Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, ClientId);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (MsgId == NETMSGTYPE_CL_RACESHOWOTHERS)
|
||||
{
|
||||
if(!g_Config.m_SvShowOthers && !Server()->IsAuthed(ClientId))
|
||||
return;
|
||||
if(pPlayer->m_Last_ShowOthers && pPlayer->m_Last_ShowOthers+Server()->TickSpeed()/2 > Server()->Tick())
|
||||
return;
|
||||
pPlayer->m_Last_ShowOthers = Server()->Tick();
|
||||
CNetMsg_Cl_RaceShowOthers *pMsg = (CNetMsg_Cl_RaceShowOthers *)pRawMsg;
|
||||
pPlayer->m_ShowOthers = (bool)pMsg->m_Active;
|
||||
if(pPlayer->m_ShowOthers)
|
||||
{
|
||||
((CGameControllerDDRace*)m_pController)->m_Teams.SendAllInfo(pPlayer->GetCID());
|
||||
}
|
||||
}
|
||||
else if(MsgId == NETMSGTYPE_CL_CALLVOTE)
|
||||
{
|
||||
|
|
|
@ -31,11 +31,6 @@ CPlayer::CPlayer(CGameContext *pGameServer, int CID, int Team)
|
|||
m_SentAfkWarning2 = 0;
|
||||
|
||||
m_PauseInfo.m_Respawn = false;
|
||||
|
||||
m_ShowOthers = false;
|
||||
|
||||
m_IsUsingRaceClient = false;
|
||||
m_LastSentTime = 0;
|
||||
|
||||
GameServer()->Score()->PlayerData(CID)->Reset();
|
||||
|
||||
|
@ -95,24 +90,6 @@ void CPlayer::Tick()
|
|||
}
|
||||
else if(m_Spawning && m_RespawnTick <= Server()->Tick())
|
||||
TryRespawn();
|
||||
|
||||
// send best time
|
||||
if(m_IsUsingRaceClient)
|
||||
{
|
||||
if(m_LastSentTime > GameServer()->m_pController->m_CurrentRecord || (m_LastSentTime == 0 && GameServer()->m_pController->m_CurrentRecord > 0))
|
||||
{
|
||||
//dbg_msg("player", "Record message sended");
|
||||
char aBuf[16];
|
||||
str_format(aBuf, sizeof(aBuf), "%.0f", GameServer()->m_pController->m_CurrentRecord*100.0f); // damn ugly but the only way i know to do it
|
||||
int TimeToSend;
|
||||
sscanf(aBuf, "%d", &TimeToSend);
|
||||
CNetMsg_Sv_Record Msg;
|
||||
Msg.m_Time = TimeToSend;
|
||||
Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, m_ClientID);
|
||||
|
||||
m_LastSentTime = GameServer()->m_pController->m_CurrentRecord;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CPlayer::Snap(int SnappingClient)
|
||||
|
|
|
@ -79,12 +79,8 @@ public:
|
|||
int64 m_Last_Emote;
|
||||
int64 m_Last_Kill;
|
||||
|
||||
int m_Last_ShowOthers;
|
||||
|
||||
bool m_ShowOthers;
|
||||
bool m_Invisible;
|
||||
|
||||
//DDRace
|
||||
int m_Muted;
|
||||
//int hammer_ type;
|
||||
|
||||
|
@ -93,8 +89,7 @@ public:
|
|||
int m_Resistent;
|
||||
|
||||
bool m_ColorSet; // Set if player changed color at least once
|
||||
|
||||
//DDRace var
|
||||
|
||||
int m_Starttime;
|
||||
int m_Refreshtime;
|
||||
int m_RaceState;
|
||||
|
@ -122,9 +117,6 @@ public:
|
|||
|
||||
bool m_ResetPickups;
|
||||
|
||||
bool m_IsUsingRaceClient;
|
||||
float m_LastSentTime;
|
||||
|
||||
// afk timer
|
||||
void AfkTimer(int new_target_x, int new_target_y);
|
||||
int64 m_LastPlaytime;
|
||||
|
|
|
@ -91,14 +91,6 @@ bool CGameTeams::SetCharacterTeam(int id, int Team) {
|
|||
str_format(aBuf, sizeof(aBuf), "Id = %d Team = %d", id, Team);
|
||||
dbg_msg("Teams", aBuf);
|
||||
//GameServer()->CreatePlayerSpawn(Character(id)->m_Core.m_Pos, TeamMask());
|
||||
if(Character(id)->GetPlayer()->m_IsUsingRaceClient)
|
||||
{
|
||||
CNetMsg_Sv_PlayerTeam Msg;
|
||||
Msg.m_Team = Team;
|
||||
Msg.m_Cid = id;
|
||||
Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, -1);
|
||||
//dbg_msg("Teams", "Sended all");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -142,22 +134,10 @@ int CGameTeams::TeamMask(int Team) {
|
|||
for(int i = 0; i < MAX_CLIENTS; ++i) {
|
||||
if(m_Core.Team(i) == Team
|
||||
|| (Character(i)
|
||||
&& Character(i)->GetPlayer()
|
||||
&& Character(i)->GetPlayer()->m_ShowOthers)
|
||||
&& Character(i)->GetPlayer())
|
||||
|| m_Core.Team(i) == TEAM_SUPER) {
|
||||
Mask |= 1 << i;
|
||||
}
|
||||
}
|
||||
return Mask;
|
||||
}
|
||||
|
||||
void CGameTeams::SendAllInfo(int Cid) {
|
||||
for(int i = 0; i < MAX_CLIENTS; ++i) {
|
||||
if(m_Core.Team(i) != 0) {
|
||||
CNetMsg_Sv_PlayerTeam Msg;
|
||||
Msg.m_Team = m_Core.Team(i);
|
||||
Msg.m_Cid = i;
|
||||
Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, Cid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,8 +40,6 @@ public:
|
|||
|
||||
int TeamMask(int Team);
|
||||
|
||||
void SendAllInfo(int Cid);
|
||||
|
||||
//need to be very carefull using this method
|
||||
void SetForceCharacterTeam(int id, int Team);
|
||||
|
||||
|
|
Loading…
Reference in a new issue