mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
fix some tele number picker issues
This commit is contained in:
parent
1a5f0ed6a2
commit
1c870a3e1b
|
@ -3322,6 +3322,9 @@ int CEditor::DoProperties(CUIRect *pToolBox, CProperty *pProps, int *pIDs, int *
|
|||
}
|
||||
}
|
||||
|
||||
if(Change != -1)
|
||||
*pNewVal = clamp(*pNewVal, pProps[Change].m_Min, pProps->m_Max);
|
||||
|
||||
return Change;
|
||||
}
|
||||
|
||||
|
|
|
@ -1091,6 +1091,7 @@ public:
|
|||
virtual void BrushFlipY();
|
||||
virtual void BrushRotate(float Amount);
|
||||
virtual void FillSelection(bool Empty, CLayer *pBrush, CUIRect Rect);
|
||||
virtual bool ContainsElementWithId(int Id);
|
||||
};
|
||||
|
||||
class CLayerSpeedup : public CLayerTiles
|
||||
|
|
|
@ -230,8 +230,18 @@ int CLayerTiles::BrushGrab(CLayerGroup *pBrush, CUIRect Rect)
|
|||
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 || pGrabbed->m_pTeleTile[y*pGrabbed->m_Width+x].m_Type == TILE_TELECHECKINEVIL || pGrabbed->m_pTeleTile[y*pGrabbed->m_Width+x].m_Type == TILE_TELECHECK || pGrabbed->m_pTeleTile[y*pGrabbed->m_Width+x].m_Type == TILE_TELECHECKOUT || pGrabbed->m_pTeleTile[y*pGrabbed->m_Width+x].m_Type == TILE_TELECHECKIN || pGrabbed->m_pTeleTile[y*pGrabbed->m_Width+x].m_Type == TILE_TELEINWEAPON || pGrabbed->m_pTeleTile[y*pGrabbed->m_Width+x].m_Type == TILE_TELEINHOOK)
|
||||
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
|
||||
// || pGrabbed->m_pTeleTile[y*pGrabbed->m_Width+x].m_Type == TILE_TELECHECKINEVIL
|
||||
|| pGrabbed->m_pTeleTile[y*pGrabbed->m_Width+x].m_Type == TILE_TELECHECK
|
||||
|| pGrabbed->m_pTeleTile[y*pGrabbed->m_Width+x].m_Type == TILE_TELECHECKOUT
|
||||
// || pGrabbed->m_pTeleTile[y*pGrabbed->m_Width+x].m_Type == TILE_TELECHECKIN
|
||||
|| pGrabbed->m_pTeleTile[y*pGrabbed->m_Width+x].m_Type == TILE_TELEINWEAPON
|
||||
|| pGrabbed->m_pTeleTile[y*pGrabbed->m_Width+x].m_Type == TILE_TELEINHOOK)
|
||||
{
|
||||
m_pEditor->m_TeleNumber = pGrabbed->m_pTeleTile[y*pGrabbed->m_Width+x].m_Number;
|
||||
}
|
||||
}
|
||||
pGrabbed->m_TeleNum = m_pEditor->m_TeleNumber;
|
||||
str_copy(pGrabbed->m_aFileName, m_pEditor->m_aFileName, sizeof(pGrabbed->m_aFileName));
|
||||
|
@ -1361,6 +1371,22 @@ void CLayerTele::FillSelection(bool Empty, CLayer *pBrush, CUIRect Rect)
|
|||
FlagModified(sx, sy, w, h);
|
||||
}
|
||||
|
||||
bool CLayerTele::ContainsElementWithId(int Id)
|
||||
{
|
||||
for(int y = 0; y < m_Height; ++y)
|
||||
{
|
||||
for(int x = 0; x < m_Width; ++x)
|
||||
{
|
||||
if(m_pTeleTile[y*m_Width+x].m_Number == Id)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
CLayerSpeedup::CLayerSpeedup(int w, int h)
|
||||
: CLayerTiles(w, h)
|
||||
{
|
||||
|
|
|
@ -1435,49 +1435,62 @@ int CEditor::PopupSelectConfigAutoMapResult()
|
|||
|
||||
int CEditor::PopupTele(CEditor *pEditor, CUIRect View, void *pContext)
|
||||
{
|
||||
static int previousTeleNumber = -1;
|
||||
|
||||
CUIRect Button;
|
||||
CUIRect FindEmptySlot;
|
||||
|
||||
View.HSplitBottom(12.0f, &View, &Button);
|
||||
Button.VSplitRight(15.f, &Button, &FindEmptySlot);
|
||||
Button.VSplitRight(2.f, &Button, 0);
|
||||
|
||||
static int emptySlotPid = 0;
|
||||
if (pEditor->DoButton_Editor(&emptySlotPid, "F", 0, &FindEmptySlot, 0, "Find empty slot"))
|
||||
{
|
||||
int number = -1;
|
||||
for(int i = 1; i <= 255; i++)
|
||||
{
|
||||
if(!pEditor->m_Map.m_pTeleLayer->ContainsElementWithId(i))
|
||||
{
|
||||
number = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(number != -1)
|
||||
{
|
||||
pEditor->m_TeleNumber = number;
|
||||
}
|
||||
}
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_TELE=0,
|
||||
NUM_PROPS,
|
||||
};
|
||||
|
||||
CProperty aProps[] = {
|
||||
{"Number", pEditor->m_TeleNumber, PROPTYPE_INT_STEP, 0, 255},
|
||||
{"Number", pEditor->m_TeleNumber, PROPTYPE_INT_STEP, 1, 255},
|
||||
{0},
|
||||
};
|
||||
|
||||
static int s_aIds[NUM_PROPS] = {0};
|
||||
int NewVal = 0;
|
||||
static ColorRGBA s_color = ColorRGBA(1,1,1,0.5f);
|
||||
|
||||
int Prop = pEditor->DoProperties(&View, aProps, s_aIds, &NewVal, s_color);
|
||||
static ColorRGBA s_color = ColorRGBA(0.5f, 1, 0.5f, 0.5f);
|
||||
|
||||
static int NewVal = 0;
|
||||
int Prop = pEditor->DoProperties(&Button, aProps, s_aIds, &NewVal, s_color);
|
||||
if(Prop == PROP_TELE)
|
||||
{
|
||||
NewVal = (NewVal + 256) % 256;
|
||||
|
||||
CLayerTele *gl = pEditor->m_Map.m_pTeleLayer;
|
||||
for(int y = 0; y < gl->m_Height; ++y)
|
||||
{
|
||||
for(int x = 0; x < gl->m_Width; ++x)
|
||||
{
|
||||
if(gl->m_pTeleTile[y*gl->m_Width+x].m_Number == NewVal)
|
||||
{
|
||||
s_color = ColorRGBA(1,0.5f,0.5f,0.5f);
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
s_color = ColorRGBA(0.5f,1,0.5f,0.5f);
|
||||
|
||||
done:
|
||||
pEditor->m_TeleNumber = NewVal;
|
||||
pEditor->m_TeleNumber = (NewVal + 256) % 256;
|
||||
}
|
||||
|
||||
if(previousTeleNumber == 1 || previousTeleNumber != pEditor->m_TeleNumber)
|
||||
{
|
||||
s_color = pEditor->m_Map.m_pTeleLayer->ContainsElementWithId(pEditor->m_TeleNumber)
|
||||
? ColorRGBA(1, 0.5f, 0.5f, 0.5f)
|
||||
: ColorRGBA(0.5f, 1, 0.5f, 0.5f);
|
||||
}
|
||||
previousTeleNumber = pEditor->m_TeleNumber;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue