Parallax Zoom: Add default zoom option to the editor

Safe defaults for map editing: unless opted-in, Parallax Zoom
will default to maximum(parallax{x,y}).
This commit is contained in:
Fireball 2022-08-06 01:31:42 +01:00
parent a90c86e9a5
commit 5bf7f60bf6
4 changed files with 18 additions and 1 deletions

View file

@ -3345,7 +3345,7 @@ void CEditor::RenderLayers(CUIRect ToolBox, CUIRect View)
static int s_GroupPopupId = 0;
if(Result == 2)
UiInvokePopupMenu(&s_GroupPopupId, 0, UI()->MouseX(), UI()->MouseY(), 145, 230, PopupGroup);
UiInvokePopupMenu(&s_GroupPopupId, 0, UI()->MouseX(), UI()->MouseY(), 145, 256, PopupGroup);
if(!m_Map.m_vpGroups[g]->m_vpLayers.empty() && Input()->MouseDoubleClick())
m_Map.m_vpGroups[g]->m_Collapse ^= 1;

View file

@ -176,6 +176,7 @@ public:
int m_ParallaxX;
int m_ParallaxY;
int m_CustomParallaxZoom;
int m_ParallaxZoom;
int m_UseClipping;
@ -242,6 +243,12 @@ public:
}
}*/
void OnEdited()
{
if(!m_CustomParallaxZoom)
m_ParallaxZoom = maximum(m_ParallaxX, m_ParallaxY);
}
void Clear()
{
m_vpLayers.clear();

View file

@ -610,6 +610,7 @@ int CEditorMap::Load(class IStorage *pStorage, const char *pFileName, int Storag
IntsToStr(pGItem->m_aName, sizeof(pGroup->m_aName) / sizeof(int), pGroup->m_aName);
pGroup->m_ParallaxZoom = pGItem->GetParallaxZoom();
pGroup->m_CustomParallaxZoom = pGroup->m_ParallaxZoom != maximum(pGroup->m_ParallaxX, pGroup->m_ParallaxY);
for(int l = 0; l < pGItem->m_NumLayers; l++)
{

View file

@ -320,6 +320,7 @@ int CEditor::PopupGroup(CEditor *pEditor, CUIRect View, void *pContext)
PROP_POS_Y,
PROP_PARA_X,
PROP_PARA_Y,
PROP_CUSTOM_ZOOM,
PROP_PARA_ZOOM,
PROP_USE_CLIPPING,
PROP_CLIP_X,
@ -335,6 +336,7 @@ int CEditor::PopupGroup(CEditor *pEditor, CUIRect View, void *pContext)
{"Pos Y", -pEditor->m_Map.m_vpGroups[pEditor->m_SelectedGroup]->m_OffsetY, PROPTYPE_INT_SCROLL, -1000000, 1000000},
{"Para X", pEditor->m_Map.m_vpGroups[pEditor->m_SelectedGroup]->m_ParallaxX, PROPTYPE_INT_SCROLL, -1000000, 1000000},
{"Para Y", pEditor->m_Map.m_vpGroups[pEditor->m_SelectedGroup]->m_ParallaxY, PROPTYPE_INT_SCROLL, -1000000, 1000000},
{"Custom Zoom", pEditor->m_Map.m_vpGroups[pEditor->m_SelectedGroup]->m_CustomParallaxZoom, PROPTYPE_BOOL, 0, 1},
{"Para Zoom", pEditor->m_Map.m_vpGroups[pEditor->m_SelectedGroup]->m_ParallaxZoom, PROPTYPE_INT_SCROLL, -1000000, 1000000},
{"Use Clipping", pEditor->m_Map.m_vpGroups[pEditor->m_SelectedGroup]->m_UseClipping, PROPTYPE_BOOL, 0, 1},
@ -366,8 +368,13 @@ int CEditor::PopupGroup(CEditor *pEditor, CUIRect View, void *pContext)
pEditor->m_Map.m_vpGroups[pEditor->m_SelectedGroup]->m_ParallaxX = NewVal;
else if(Prop == PROP_PARA_Y)
pEditor->m_Map.m_vpGroups[pEditor->m_SelectedGroup]->m_ParallaxY = NewVal;
else if(Prop == PROP_CUSTOM_ZOOM)
pEditor->m_Map.m_vpGroups[pEditor->m_SelectedGroup]->m_CustomParallaxZoom = NewVal;
else if(Prop == PROP_PARA_ZOOM)
{
pEditor->m_Map.m_vpGroups[pEditor->m_SelectedGroup]->m_CustomParallaxZoom = 1;
pEditor->m_Map.m_vpGroups[pEditor->m_SelectedGroup]->m_ParallaxZoom = NewVal;
}
else if(Prop == PROP_POS_X)
pEditor->m_Map.m_vpGroups[pEditor->m_SelectedGroup]->m_OffsetX = -NewVal;
else if(Prop == PROP_POS_Y)
@ -382,6 +389,8 @@ int CEditor::PopupGroup(CEditor *pEditor, CUIRect View, void *pContext)
pEditor->m_Map.m_vpGroups[pEditor->m_SelectedGroup]->m_ClipW = NewVal;
else if(Prop == PROP_CLIP_H)
pEditor->m_Map.m_vpGroups[pEditor->m_SelectedGroup]->m_ClipH = NewVal;
pEditor->m_Map.m_vpGroups[pEditor->m_SelectedGroup]->OnEdited();
}
return 0;