This commit is contained in:
Learath 2020-09-22 15:47:21 +03:00
parent 586043fc64
commit bbdcb7035d
3 changed files with 24 additions and 18 deletions

View file

@ -45,8 +45,14 @@ constexpr inline int f2fx(float v) { return (int)(v*(float)(1<<10)); }
constexpr inline float fx2f(int v) { return v*(1.0f/(1<<10)); } constexpr inline float fx2f(int v) { return v*(1.0f/(1<<10)); }
// int to fixed // int to fixed
inline int i2fx(int v) { return v<<10; } inline int i2fx(int v)
inline int fx2i(int v) { return v>>10; } {
return v << 10;
}
inline int fx2i(int v)
{
return v >> 10;
}
inline int gcd(int a, int b) inline int gcd(int a, int b)
{ {

View file

@ -2409,14 +2409,14 @@ void CEditor::DoMapEditor(CUIRect View)
m_QuadsetPicker.m_Image = t->m_Image; m_QuadsetPicker.m_Image = t->m_Image;
m_QuadsetPicker.m_lQuads[0].m_aPoints[0].x = f2fx(View.x); m_QuadsetPicker.m_lQuads[0].m_aPoints[0].x = f2fx(View.x);
m_QuadsetPicker.m_lQuads[0].m_aPoints[0].y = f2fx(View.y); m_QuadsetPicker.m_lQuads[0].m_aPoints[0].y = f2fx(View.y);
m_QuadsetPicker.m_lQuads[0].m_aPoints[1].x = f2fx((View.x+View.w)); m_QuadsetPicker.m_lQuads[0].m_aPoints[1].x = f2fx((View.x + View.w));
m_QuadsetPicker.m_lQuads[0].m_aPoints[1].y = f2fx(View.y); m_QuadsetPicker.m_lQuads[0].m_aPoints[1].y = f2fx(View.y);
m_QuadsetPicker.m_lQuads[0].m_aPoints[2].x = f2fx(View.x); m_QuadsetPicker.m_lQuads[0].m_aPoints[2].x = f2fx(View.x);
m_QuadsetPicker.m_lQuads[0].m_aPoints[2].y = f2fx((View.y+View.h)); m_QuadsetPicker.m_lQuads[0].m_aPoints[2].y = f2fx((View.y + View.h));
m_QuadsetPicker.m_lQuads[0].m_aPoints[3].x = f2fx((View.x+View.w)); m_QuadsetPicker.m_lQuads[0].m_aPoints[3].x = f2fx((View.x + View.w));
m_QuadsetPicker.m_lQuads[0].m_aPoints[3].y = f2fx((View.y+View.h)); m_QuadsetPicker.m_lQuads[0].m_aPoints[3].y = f2fx((View.y + View.h));
m_QuadsetPicker.m_lQuads[0].m_aPoints[4].x = f2fx((View.x+View.w/2)); m_QuadsetPicker.m_lQuads[0].m_aPoints[4].x = f2fx((View.x + View.w / 2));
m_QuadsetPicker.m_lQuads[0].m_aPoints[4].y = f2fx((View.y+View.h/2)); m_QuadsetPicker.m_lQuads[0].m_aPoints[4].y = f2fx((View.y + View.h / 2));
m_QuadsetPicker.Render(); m_QuadsetPicker.Render();
} }
} }
@ -3357,7 +3357,7 @@ void CEditor::RenderLayers(CUIRect ToolBox, CUIRect View)
if (g != m_SelectedGroup) if (g != m_SelectedGroup)
SelectLayer(0, g); SelectLayer(0, g);
if ((Input()->KeyIsPressed(KEY_LSHIFT) || Input()->KeyIsPressed(KEY_RSHIFT)) && m_SelectedGroup == g) if((Input()->KeyIsPressed(KEY_LSHIFT) || Input()->KeyIsPressed(KEY_RSHIFT)) && m_SelectedGroup == g)
{ {
for(int i = 1; i < m_Map.m_lGroups[g]->m_lLayers.size(); i++) for(int i = 1; i < m_Map.m_lGroups[g]->m_lLayers.size(); i++)
{ {
@ -3477,7 +3477,7 @@ void CEditor::RenderLayers(CUIRect ToolBox, CUIRect View)
} }
} }
if (!IsLayerSelected) if(!IsLayerSelected)
{ {
SelectLayer(i, g); SelectLayer(i, g);
} }

View file

@ -592,9 +592,9 @@ int CEditor::PopupQuad(CEditor *pEditor, CUIRect View, void *pContext)
CProperty aProps[] = { CProperty aProps[] = {
{"Pos X", fx2i(pCurrentQuad->m_aPoints[4].x), PROPTYPE_INT_SCROLL, -1000000, 1000000}, {"Pos X", fx2i(pCurrentQuad->m_aPoints[4].x), PROPTYPE_INT_SCROLL, -1000000, 1000000},
{"Pos Y", fx2i(pCurrentQuad->m_aPoints[4].y), PROPTYPE_INT_SCROLL, -1000000, 1000000}, {"Pos Y", fx2i(pCurrentQuad->m_aPoints[4].y), PROPTYPE_INT_SCROLL, -1000000, 1000000},
{"Pos. Env", pCurrentQuad->m_PosEnv+1, PROPTYPE_ENVELOPE, 0, 0}, {"Pos. Env", pCurrentQuad->m_PosEnv + 1, PROPTYPE_ENVELOPE, 0, 0},
{"Pos. TO", pCurrentQuad->m_PosEnvOffset, PROPTYPE_INT_SCROLL, -1000000, 1000000}, {"Pos. TO", pCurrentQuad->m_PosEnvOffset, PROPTYPE_INT_SCROLL, -1000000, 1000000},
{"Color Env", pCurrentQuad->m_ColorEnv+1, PROPTYPE_ENVELOPE, 0, 0}, {"Color Env", pCurrentQuad->m_ColorEnv + 1, PROPTYPE_ENVELOPE, 0, 0},
{"Color TO", pCurrentQuad->m_ColorEnvOffset, PROPTYPE_INT_SCROLL, -1000000, 1000000}, {"Color TO", pCurrentQuad->m_ColorEnvOffset, PROPTYPE_INT_SCROLL, -1000000, 1000000},
{0}, {0},
@ -896,13 +896,13 @@ int CEditor::PopupPoint(CEditor *pEditor, CUIRect View, void *pContext)
if(Prop == PROP_POS_X) if(Prop == PROP_POS_X)
{ {
for(int v = 0; v < 4; v++) for(int v = 0; v < 4; v++)
if(pEditor->m_SelectedPoints&(1<<v)) if(pEditor->m_SelectedPoints & (1 << v))
lQuads[i]->m_aPoints[v].x = i2fx(NewVal); lQuads[i]->m_aPoints[v].x = i2fx(NewVal);
} }
if(Prop == PROP_POS_Y) if(Prop == PROP_POS_Y)
{ {
for(int v = 0; v < 4; v++) for(int v = 0; v < 4; v++)
if(pEditor->m_SelectedPoints&(1<<v)) if(pEditor->m_SelectedPoints & (1 << v))
lQuads[i]->m_aPoints[v].y = i2fx(NewVal); lQuads[i]->m_aPoints[v].y = i2fx(NewVal);
} }
if(Prop == PROP_COLOR) if(Prop == PROP_COLOR)
@ -921,14 +921,14 @@ int CEditor::PopupPoint(CEditor *pEditor, CUIRect View, void *pContext)
if(Prop == PROP_TEX_U) if(Prop == PROP_TEX_U)
{ {
for(int v = 0; v < 4; v++) for(int v = 0; v < 4; v++)
if(pEditor->m_SelectedPoints&(1<<v)) if(pEditor->m_SelectedPoints & (1 << v))
lQuads[i]->m_aTexcoords[v].x = f2fx(NewVal/1024.0f); lQuads[i]->m_aTexcoords[v].x = f2fx(NewVal / 1024.0f);
} }
if(Prop == PROP_TEX_V) if(Prop == PROP_TEX_V)
{ {
for(int v = 0; v < 4; v++) for(int v = 0; v < 4; v++)
if(pEditor->m_SelectedPoints&(1<<v)) if(pEditor->m_SelectedPoints & (1 << v))
lQuads[i]->m_aTexcoords[v].y = f2fx(NewVal/1024.0f); lQuads[i]->m_aTexcoords[v].y = f2fx(NewVal / 1024.0f);
} }
} }