Merge pull request #7626 from archimede67/fix-editor-modified-state

Fix editor modified state not being updated properly
This commit is contained in:
Dennis Felsing 2023-12-11 11:17:28 +00:00 committed by GitHub
commit 79b016b7a0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 28 additions and 7 deletions

View file

@ -1178,7 +1178,7 @@ void CChat::OnRender()
m_Input.Activate(EInputPriority::CHAT); // Ensure that the input is active m_Input.Activate(EInputPriority::CHAT); // Ensure that the input is active
const CUIRect InputCursorRect = {Cursor.m_X, Cursor.m_Y - ScrollOffset, 0.0f, 0.0f}; const CUIRect InputCursorRect = {Cursor.m_X, Cursor.m_Y - ScrollOffset, 0.0f, 0.0f};
const STextBoundingBox BoundingBox = m_Input.Render(&InputCursorRect, Cursor.m_FontSize, TEXTALIGN_TL, m_Input.WasChanged(), MessageMaxWidth, 0.0f); const STextBoundingBox BoundingBox = m_Input.Render(&InputCursorRect, Cursor.m_FontSize, TEXTALIGN_TL, m_Input.WasCursorChanged(), MessageMaxWidth, 0.0f);
Graphics()->ClipDisable(); Graphics()->ClipDisable();

View file

@ -767,7 +767,7 @@ void CGameConsole::OnRender()
pConsole->m_Input.SetHidden(m_ConsoleType == CONSOLETYPE_REMOTE && Client()->State() == IClient::STATE_ONLINE && !Client()->RconAuthed() && (pConsole->m_UserGot || !pConsole->m_UsernameReq)); pConsole->m_Input.SetHidden(m_ConsoleType == CONSOLETYPE_REMOTE && Client()->State() == IClient::STATE_ONLINE && !Client()->RconAuthed() && (pConsole->m_UserGot || !pConsole->m_UsernameReq));
pConsole->m_Input.Activate(EInputPriority::CONSOLE); // Ensure that the input is active pConsole->m_Input.Activate(EInputPriority::CONSOLE); // Ensure that the input is active
const CUIRect InputCursorRect = {x, y + FONT_SIZE, 0.0f, 0.0f}; const CUIRect InputCursorRect = {x, y + FONT_SIZE, 0.0f, 0.0f};
pConsole->m_BoundingBox = pConsole->m_Input.Render(&InputCursorRect, FONT_SIZE, TEXTALIGN_BL, pConsole->m_Input.WasChanged(), Screen.w - 10.0f - x, LINE_SPACING); pConsole->m_BoundingBox = pConsole->m_Input.Render(&InputCursorRect, FONT_SIZE, TEXTALIGN_BL, pConsole->m_Input.WasCursorChanged(), Screen.w - 10.0f - x, LINE_SPACING);
if(pConsole->m_LastInputHeight == 0.0f && pConsole->m_BoundingBox.m_H != 0.0f) if(pConsole->m_LastInputHeight == 0.0f && pConsole->m_BoundingBox.m_H != 0.0f)
pConsole->m_LastInputHeight = pConsole->m_BoundingBox.m_H; pConsole->m_LastInputHeight = pConsole->m_BoundingBox.m_H;
if(pConsole->m_Input.HasSelection()) if(pConsole->m_Input.HasSelection())

View file

@ -86,6 +86,7 @@ void CLineInput::SetRange(const char *pString, size_t Begin, size_t End)
m_Len += AddedCharSize - RemovedCharSize; m_Len += AddedCharSize - RemovedCharSize;
m_NumChars += AddedCharCount - RemovedCharCount; m_NumChars += AddedCharCount - RemovedCharCount;
m_WasChanged = true; m_WasChanged = true;
m_WasCursorChanged = true;
m_pStr[m_Len] = '\0'; m_pStr[m_Len] = '\0';
m_SelectionStart = m_SelectionEnd = m_CursorPos; m_SelectionStart = m_SelectionEnd = m_CursorPos;
} }
@ -158,7 +159,7 @@ void CLineInput::MoveCursor(EMoveDirection Direction, bool MoveWord, const char
void CLineInput::SetCursorOffset(size_t Offset) void CLineInput::SetCursorOffset(size_t Offset)
{ {
m_SelectionStart = m_SelectionEnd = m_LastCompositionCursorPos = m_CursorPos = clamp<size_t>(Offset, 0, m_Len); m_SelectionStart = m_SelectionEnd = m_LastCompositionCursorPos = m_CursorPos = clamp<size_t>(Offset, 0, m_Len);
m_WasChanged = true; m_WasCursorChanged = true;
} }
void CLineInput::SetSelection(size_t Start, size_t End) void CLineInput::SetSelection(size_t Start, size_t End)
@ -168,7 +169,7 @@ void CLineInput::SetSelection(size_t Start, size_t End)
std::swap(Start, End); std::swap(Start, End);
m_SelectionStart = clamp<size_t>(Start, 0, m_Len); m_SelectionStart = clamp<size_t>(Start, 0, m_Len);
m_SelectionEnd = clamp<size_t>(End, 0, m_Len); m_SelectionEnd = clamp<size_t>(End, 0, m_Len);
m_WasChanged = true; m_WasCursorChanged = true;
} }
size_t CLineInput::OffsetFromActualToDisplay(size_t ActualOffset) size_t CLineInput::OffsetFromActualToDisplay(size_t ActualOffset)
@ -383,9 +384,9 @@ bool CLineInput::ProcessInput(const IInput::CEvent &Event)
} }
} }
m_WasChanged |= OldCursorPos != m_CursorPos; m_WasCursorChanged |= OldCursorPos != m_CursorPos;
m_WasChanged |= SelectionLength != GetSelectionLength(); m_WasChanged |= SelectionLength != GetSelectionLength();
return m_WasChanged || KeyHandled; return m_WasChanged || m_WasCursorChanged || KeyHandled;
} }
STextBoundingBox CLineInput::Render(const CUIRect *pRect, float FontSize, int Align, bool Changed, float LineWidth, float LineSpacing) STextBoundingBox CLineInput::Render(const CUIRect *pRect, float FontSize, int Align, bool Changed, float LineWidth, float LineSpacing)

View file

@ -77,6 +77,7 @@ private:
FDisplayTextCallback m_pfnDisplayTextCallback; FDisplayTextCallback m_pfnDisplayTextCallback;
FCalculateOffsetCallback m_pfnCalculateOffsetCallback; FCalculateOffsetCallback m_pfnCalculateOffsetCallback;
bool m_WasChanged; bool m_WasChanged;
bool m_WasCursorChanged;
bool m_WasRendered; bool m_WasRendered;
char m_ClearButtonId; char m_ClearButtonId;
@ -179,6 +180,12 @@ public:
m_WasChanged = false; m_WasChanged = false;
return Changed; return Changed;
} }
bool WasCursorChanged()
{
const bool Changed = m_WasCursorChanged;
m_WasCursorChanged = false;
return Changed;
}
STextBoundingBox Render(const CUIRect *pRect, float FontSize, int Align, bool Changed, float LineWidth, float LineSpacing); STextBoundingBox Render(const CUIRect *pRect, float FontSize, int Align, bool Changed, float LineWidth, float LineSpacing);
SMouseSelection *GetMouseSelection() { return &m_MouseSelection; } SMouseSelection *GetMouseSelection() { return &m_MouseSelection; }

View file

@ -5674,6 +5674,7 @@ void CEditor::RenderEnvelopeEditor(CUIRect View)
if(m_SelectedEnvelope >= (int)m_Map.m_vpEnvelopes.size()) if(m_SelectedEnvelope >= (int)m_Map.m_vpEnvelopes.size())
m_SelectedEnvelope = m_Map.m_vpEnvelopes.size() - 1; m_SelectedEnvelope = m_Map.m_vpEnvelopes.size() - 1;
pEnvelope = m_SelectedEnvelope >= 0 ? m_Map.m_vpEnvelopes[m_SelectedEnvelope] : nullptr; pEnvelope = m_SelectedEnvelope >= 0 ? m_Map.m_vpEnvelopes[m_SelectedEnvelope] : nullptr;
m_Map.OnModify();
} }
// Move right button // Move right button
@ -5686,6 +5687,7 @@ void CEditor::RenderEnvelopeEditor(CUIRect View)
m_Map.SwapEnvelopes(m_SelectedEnvelope, m_SelectedEnvelope + 1); m_Map.SwapEnvelopes(m_SelectedEnvelope, m_SelectedEnvelope + 1);
m_SelectedEnvelope = clamp<int>(m_SelectedEnvelope + 1, 0, m_Map.m_vpEnvelopes.size() - 1); m_SelectedEnvelope = clamp<int>(m_SelectedEnvelope + 1, 0, m_Map.m_vpEnvelopes.size() - 1);
pEnvelope = m_Map.m_vpEnvelopes[m_SelectedEnvelope]; pEnvelope = m_Map.m_vpEnvelopes[m_SelectedEnvelope];
m_Map.OnModify();
} }
// Move left button // Move left button
@ -5697,6 +5699,7 @@ void CEditor::RenderEnvelopeEditor(CUIRect View)
m_Map.SwapEnvelopes(m_SelectedEnvelope - 1, m_SelectedEnvelope); m_Map.SwapEnvelopes(m_SelectedEnvelope - 1, m_SelectedEnvelope);
m_SelectedEnvelope = clamp<int>(m_SelectedEnvelope - 1, 0, m_Map.m_vpEnvelopes.size() - 1); m_SelectedEnvelope = clamp<int>(m_SelectedEnvelope - 1, 0, m_Map.m_vpEnvelopes.size() - 1);
pEnvelope = m_Map.m_vpEnvelopes[m_SelectedEnvelope]; pEnvelope = m_Map.m_vpEnvelopes[m_SelectedEnvelope];
m_Map.OnModify();
} }
if(pEnvelope) if(pEnvelope)
@ -5875,6 +5878,7 @@ void CEditor::RenderEnvelopeEditor(CUIRect View)
{ {
m_EnvelopeEditorHistory.RecordAction(std::make_shared<CEditorActionEnvelopeEdit>(this, m_SelectedEnvelope, CEditorActionEnvelopeEdit::EEditType::SYNC, pEnvelope->m_Synchronized, !pEnvelope->m_Synchronized)); m_EnvelopeEditorHistory.RecordAction(std::make_shared<CEditorActionEnvelopeEdit>(this, m_SelectedEnvelope, CEditorActionEnvelopeEdit::EEditType::SYNC, pEnvelope->m_Synchronized, !pEnvelope->m_Synchronized));
pEnvelope->m_Synchronized = !pEnvelope->m_Synchronized; pEnvelope->m_Synchronized = !pEnvelope->m_Synchronized;
m_Map.OnModify();
} }
ToolBar.VSplitLeft(4.0f, nullptr, &ToolBar); ToolBar.VSplitLeft(4.0f, nullptr, &ToolBar);
@ -6172,6 +6176,7 @@ void CEditor::RenderEnvelopeEditor(CUIRect View)
m_EnvelopeEditorHistory.RecordAction(std::make_shared<CEditorActionEnvelopeEditPoint>(this, m_EnvelopeEditorHistory.RecordAction(std::make_shared<CEditorActionEnvelopeEditPoint>(this,
m_SelectedEnvelope, i, 0, CEditorActionEnvelopeEditPoint::EEditType::CURVE_TYPE, PrevCurve, pEnvelope->m_vPoints[i].m_Curvetype)); m_SelectedEnvelope, i, 0, CEditorActionEnvelopeEditPoint::EEditType::CURVE_TYPE, PrevCurve, pEnvelope->m_vPoints[i].m_Curvetype));
m_Map.OnModify();
} }
} }
} }

View file

@ -1058,7 +1058,7 @@ CUI::EPopupMenuFunctionResult CLayerTiles::RenderProperties(CUIRect *pToolBox)
m_AutoMapperConfig = -1; m_AutoMapperConfig = -1;
} }
if(Prop != ETilesProp::PROP_NONE) if(Prop != ETilesProp::PROP_NONE && Prop != ETilesProp::PROP_SHIFT_BY)
{ {
FlagModified(0, 0, m_Width, m_Height); FlagModified(0, 0, m_Width, m_Height);
} }

View file

@ -1903,6 +1903,14 @@ CUI::EPopupMenuFunctionResult CEditor::PopupMapInfo(void *pContext, CUIRect View
static int s_ConfirmButton = 0; static int s_ConfirmButton = 0;
if(pEditor->DoButton_Editor(&s_ConfirmButton, "Confirm", 0, &Label, 0, nullptr) || (Active && pEditor->UI()->ConsumeHotkey(CUI::HOTKEY_ENTER))) if(pEditor->DoButton_Editor(&s_ConfirmButton, "Confirm", 0, &Label, 0, nullptr) || (Active && pEditor->UI()->ConsumeHotkey(CUI::HOTKEY_ENTER)))
{ {
bool AuthorDifferent = str_comp(pEditor->m_Map.m_MapInfoTmp.m_aAuthor, pEditor->m_Map.m_MapInfo.m_aAuthor) != 0;
bool VersionDifferent = str_comp(pEditor->m_Map.m_MapInfoTmp.m_aVersion, pEditor->m_Map.m_MapInfo.m_aVersion) != 0;
bool CreditsDifferent = str_comp(pEditor->m_Map.m_MapInfoTmp.m_aCredits, pEditor->m_Map.m_MapInfo.m_aCredits) != 0;
bool LicenseDifferent = str_comp(pEditor->m_Map.m_MapInfoTmp.m_aLicense, pEditor->m_Map.m_MapInfo.m_aLicense) != 0;
if(AuthorDifferent || VersionDifferent || CreditsDifferent || LicenseDifferent)
pEditor->m_Map.OnModify();
pEditor->m_Map.m_MapInfo.Copy(pEditor->m_Map.m_MapInfoTmp); pEditor->m_Map.m_MapInfo.Copy(pEditor->m_Map.m_MapInfoTmp);
return CUI::POPUP_CLOSE_CURRENT; return CUI::POPUP_CLOSE_CURRENT;
} }