SHA256
Refactor Config UI Codes
This commit is contained in:
1 file changed
+158
-160
+158
-160
@@ -408,7 +408,7 @@ namespace ADOFAIRenderer.UI
|
||||
modeDropdown.RegisterValueChangedCallback(evt => UpdateVisibility(evt.newValue));
|
||||
qpField.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
warningRow.style.display = modeDropdown.value == RateControlMode.CQP.ToString() && evt.newValue == 0
|
||||
warningRow.style.display = modeDropdown.value == nameof(RateControlMode.CQP) && evt.newValue == 0
|
||||
? DisplayStyle.Flex
|
||||
: DisplayStyle.None;
|
||||
});
|
||||
@@ -739,15 +739,21 @@ namespace ADOFAIRenderer.UI
|
||||
_root.Remove(_presetConfigContainer);
|
||||
}
|
||||
|
||||
_presetConfigContainer = new VisualElement { name = "PresetSettingsContainer" };
|
||||
_presetConfigContainer.style.position = Position.Absolute;
|
||||
_presetConfigContainer.style.width = Length.Percent(100);
|
||||
_presetConfigContainer.style.height = Length.Percent(100);
|
||||
_presetConfigContainer.style.left = 0;
|
||||
_presetConfigContainer.style.top = 0;
|
||||
_presetConfigContainer.style.backgroundColor = new StyleColor(new Color(0.15f, 0.15f, 0.15f, 1.0f));
|
||||
_presetConfigContainer.style.justifyContent = Justify.Center;
|
||||
_presetConfigContainer.style.alignItems = Align.Center;
|
||||
_presetConfigContainer = new VisualElement
|
||||
{
|
||||
name = "PresetSettingsContainer",
|
||||
style =
|
||||
{
|
||||
position = Position.Absolute,
|
||||
width = Length.Percent(100),
|
||||
height = Length.Percent(100),
|
||||
left = 0,
|
||||
top = 0,
|
||||
backgroundColor = new StyleColor(new Color(0.15f, 0.15f, 0.15f, 1.0f)),
|
||||
justifyContent = Justify.Center,
|
||||
alignItems = Align.Center
|
||||
}
|
||||
};
|
||||
|
||||
// Title Row
|
||||
var titleRow = CreateRow();
|
||||
@@ -837,152 +843,7 @@ namespace ADOFAIRenderer.UI
|
||||
highButton.style.display = DisplayStyle.None;
|
||||
}
|
||||
|
||||
// Refresh Preset List
|
||||
System.Action refreshPresets = null!;
|
||||
refreshPresets = () =>
|
||||
{
|
||||
scrollView.Clear();
|
||||
var presets = PresetManager.GetPresets();
|
||||
if (presets.Count == 0)
|
||||
{
|
||||
var emptyRow = CreateRow();
|
||||
emptyRow.style.height = StyleKeyword.Auto;
|
||||
emptyRow.style.minHeight = StyleKeyword.Null;
|
||||
emptyRow.style.maxHeight = StyleKeyword.Null;
|
||||
|
||||
var emptyLabel = new Label("저장된 프리셋이 없습니다.")
|
||||
{
|
||||
style =
|
||||
{
|
||||
color = new StyleColor(Color.gray),
|
||||
unityTextAlign = TextAnchor.MiddleCenter,
|
||||
marginTop = 80,
|
||||
fontSize = 20
|
||||
}
|
||||
};
|
||||
emptyRow.Add(emptyLabel);
|
||||
scrollView.Add(emptyRow);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < presets.Count; i++)
|
||||
{
|
||||
var preset = presets[i];
|
||||
var itemRow = new VisualElement
|
||||
{
|
||||
style =
|
||||
{
|
||||
flexDirection = FlexDirection.Row,
|
||||
justifyContent = Justify.SpaceBetween,
|
||||
alignItems = Align.Center,
|
||||
paddingBottom = 5,
|
||||
paddingTop = 5,
|
||||
borderBottomWidth = (i == presets.Count - 1) ? 0 : 1,
|
||||
borderBottomColor = new StyleColor(new Color(0.2f, 0.2f, 0.2f, 0.8f))
|
||||
}
|
||||
};
|
||||
itemRow.AddToClassList("ui-row");
|
||||
|
||||
var nameLabel = new Label(preset.Name)
|
||||
{
|
||||
style =
|
||||
{
|
||||
color = new StyleColor(Color.white),
|
||||
fontSize = 30,
|
||||
flexGrow = 1
|
||||
}
|
||||
};
|
||||
|
||||
var btnContainer = new VisualElement
|
||||
{
|
||||
style = { flexDirection = FlexDirection.Row }
|
||||
};
|
||||
|
||||
var loadBtn = new Button { text = "불러오기" };
|
||||
loadBtn.style.marginRight = 10;
|
||||
loadBtn.style.width = 180f;
|
||||
loadBtn.style.marginTop = 0f;
|
||||
loadBtn.style.marginBottom = 0f;
|
||||
loadBtn.style.backgroundColor = new StyleColor(new Color(0.18f, 0.18f, 0.22f, 1.0f));
|
||||
loadBtn.style.borderTopColor = new StyleColor(new Color(0.3f, 0.3f, 0.35f, 0.8f));
|
||||
loadBtn.style.borderBottomColor = new StyleColor(new Color(0.3f, 0.3f, 0.35f, 0.8f));
|
||||
loadBtn.style.borderLeftColor = new StyleColor(new Color(0.3f, 0.3f, 0.35f, 0.8f));
|
||||
loadBtn.style.borderRightColor = new StyleColor(new Color(0.3f, 0.3f, 0.35f, 0.8f));
|
||||
loadBtn.style.borderTopWidth = 1f;
|
||||
loadBtn.style.borderBottomWidth = 1f;
|
||||
loadBtn.style.borderLeftWidth = 1f;
|
||||
loadBtn.style.borderRightWidth = 1f;
|
||||
loadBtn.style.borderTopLeftRadius = 8f;
|
||||
loadBtn.style.borderTopRightRadius = 8f;
|
||||
loadBtn.style.borderBottomLeftRadius = 8f;
|
||||
loadBtn.style.borderBottomRightRadius = 8f;
|
||||
loadBtn.style.paddingLeft = 10f;
|
||||
loadBtn.style.paddingRight = 10f;
|
||||
loadBtn.style.paddingTop = 10f;
|
||||
loadBtn.style.paddingBottom = 10f;
|
||||
loadBtn.style.fontSize = 30f;
|
||||
loadBtn.style.height = 80f;
|
||||
loadBtn.style.color = new StyleColor(Color.white);
|
||||
|
||||
loadBtn.RegisterCallback<ClickEvent>(_ =>
|
||||
{
|
||||
ApplyConfigToUI(preset.Config);
|
||||
ToggleScreens(false);
|
||||
_root.Remove(_presetConfigContainer);
|
||||
_presetConfigContainer = null;
|
||||
});
|
||||
|
||||
var deleteBtn = new Button { text = "삭제" };
|
||||
deleteBtn.style.width = 120f;
|
||||
deleteBtn.style.marginTop = 0f;
|
||||
deleteBtn.style.marginBottom = 0f;
|
||||
deleteBtn.style.backgroundColor = new StyleColor(new Color(0.25f, 0.12f, 0.12f, 1.0f));
|
||||
deleteBtn.style.borderTopColor = new StyleColor(new Color(0.45f, 0.2f, 0.2f, 0.8f));
|
||||
deleteBtn.style.borderBottomColor = new StyleColor(new Color(0.45f, 0.2f, 0.2f, 0.8f));
|
||||
deleteBtn.style.borderLeftColor = new StyleColor(new Color(0.45f, 0.2f, 0.2f, 0.8f));
|
||||
deleteBtn.style.borderRightColor = new StyleColor(new Color(0.45f, 0.2f, 0.2f, 0.8f));
|
||||
deleteBtn.style.borderTopWidth = 1f;
|
||||
deleteBtn.style.borderBottomWidth = 1f;
|
||||
deleteBtn.style.borderLeftWidth = 1f;
|
||||
deleteBtn.style.borderRightWidth = 1f;
|
||||
deleteBtn.style.borderTopLeftRadius = 8f;
|
||||
deleteBtn.style.borderTopRightRadius = 8f;
|
||||
deleteBtn.style.borderBottomLeftRadius = 8f;
|
||||
deleteBtn.style.borderBottomRightRadius = 8f;
|
||||
deleteBtn.style.paddingLeft = 10f;
|
||||
deleteBtn.style.paddingRight = 10f;
|
||||
deleteBtn.style.paddingTop = 10f;
|
||||
deleteBtn.style.paddingBottom = 10f;
|
||||
deleteBtn.style.fontSize = 30f;
|
||||
deleteBtn.style.height = 80f;
|
||||
deleteBtn.style.color = new StyleColor(Color.white);
|
||||
|
||||
deleteBtn.RegisterCallback<ClickEvent>(_ =>
|
||||
{
|
||||
CommonWarningDialogUI.ShowDialog(
|
||||
"프리셋 삭제",
|
||||
$"'{preset.Name}' 프리셋을 정말 삭제하시겠습니까?",
|
||||
new DialogButton("예", () =>
|
||||
{
|
||||
PresetManager.DeletePreset(preset.Name);
|
||||
refreshPresets();
|
||||
}),
|
||||
new DialogButton("아니오", () => {})
|
||||
);
|
||||
});
|
||||
|
||||
btnContainer.Add(loadBtn);
|
||||
btnContainer.Add(deleteBtn);
|
||||
|
||||
itemRow.Add(nameLabel);
|
||||
itemRow.Add(btnContainer);
|
||||
|
||||
scrollView.Add(itemRow);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
refreshPresets();
|
||||
RefreshPresets();
|
||||
|
||||
// Save row: Label + TextField + Save Button
|
||||
var saveRow = CreateRow();
|
||||
@@ -991,9 +852,15 @@ namespace ADOFAIRenderer.UI
|
||||
var nameLabelLabel = CreateFormLabel("새 프리셋 이름");
|
||||
nameLabelLabel.style.marginRight = 10;
|
||||
|
||||
var nameField = new TextField { label = "", name = "NewPresetName" };
|
||||
nameField.style.width = 400;
|
||||
nameField.style.marginRight = 20;
|
||||
var nameField = new TextField
|
||||
{
|
||||
label = "", name = "NewPresetName",
|
||||
style =
|
||||
{
|
||||
width = 400,
|
||||
marginRight = 20
|
||||
}
|
||||
};
|
||||
|
||||
// 기존 폼 입력 필드 스타일과 맞춤
|
||||
var textInput = nameField.Q("unity-text-input");
|
||||
@@ -1073,7 +940,7 @@ namespace ADOFAIRenderer.UI
|
||||
|
||||
PresetManager.SavePreset(presetName, currentConfig);
|
||||
nameField.value = string.Empty;
|
||||
refreshPresets();
|
||||
RefreshPresets();
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
@@ -1108,6 +975,137 @@ namespace ADOFAIRenderer.UI
|
||||
ToggleScreens(true);
|
||||
return;
|
||||
|
||||
// Refresh Preset List
|
||||
void RefreshPresets()
|
||||
{
|
||||
scrollView.Clear();
|
||||
var presets = PresetManager.GetPresets();
|
||||
if (presets.Count == 0)
|
||||
{
|
||||
var emptyRow = CreateRow();
|
||||
emptyRow.style.height = StyleKeyword.Auto;
|
||||
emptyRow.style.minHeight = StyleKeyword.Null;
|
||||
emptyRow.style.maxHeight = StyleKeyword.Null;
|
||||
|
||||
var emptyLabel = new Label("저장된 프리셋이 없습니다.") { style = { color = new StyleColor(Color.gray), unityTextAlign = TextAnchor.MiddleCenter, marginTop = 80, fontSize = 20 } };
|
||||
emptyRow.Add(emptyLabel);
|
||||
scrollView.Add(emptyRow);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < presets.Count; i++)
|
||||
{
|
||||
var preset = presets[i];
|
||||
var itemRow = new VisualElement
|
||||
{
|
||||
style =
|
||||
{
|
||||
flexDirection = FlexDirection.Row,
|
||||
justifyContent = Justify.SpaceBetween,
|
||||
alignItems = Align.Center,
|
||||
paddingBottom = 5,
|
||||
paddingTop = 5,
|
||||
borderBottomWidth = (i == presets.Count - 1) ? 0 : 1,
|
||||
borderBottomColor = new StyleColor(new Color(0.2f, 0.2f, 0.2f, 0.8f))
|
||||
}
|
||||
};
|
||||
itemRow.AddToClassList("ui-row");
|
||||
|
||||
var nameLabel = new Label(preset.Name) { style = { color = new StyleColor(Color.white), fontSize = 30, flexGrow = 1 } };
|
||||
|
||||
var btnContainer = new VisualElement { style = { flexDirection = FlexDirection.Row } };
|
||||
|
||||
var loadBtn = new Button
|
||||
{
|
||||
text = "불러오기",
|
||||
style =
|
||||
{
|
||||
marginRight = 10,
|
||||
width = 180f,
|
||||
marginTop = 0f,
|
||||
marginBottom = 0f,
|
||||
backgroundColor = new StyleColor(new Color(0.18f, 0.18f, 0.22f, 1.0f)),
|
||||
borderTopColor = new StyleColor(new Color(0.3f, 0.3f, 0.35f, 0.8f)),
|
||||
borderBottomColor = new StyleColor(new Color(0.3f, 0.3f, 0.35f, 0.8f)),
|
||||
borderLeftColor = new StyleColor(new Color(0.3f, 0.3f, 0.35f, 0.8f)),
|
||||
borderRightColor = new StyleColor(new Color(0.3f, 0.3f, 0.35f, 0.8f)),
|
||||
borderTopWidth = 1f,
|
||||
borderBottomWidth = 1f,
|
||||
borderLeftWidth = 1f,
|
||||
borderRightWidth = 1f,
|
||||
borderTopLeftRadius = 8f,
|
||||
borderTopRightRadius = 8f,
|
||||
borderBottomLeftRadius = 8f,
|
||||
borderBottomRightRadius = 8f,
|
||||
paddingLeft = 10f,
|
||||
paddingRight = 10f,
|
||||
paddingTop = 10f,
|
||||
paddingBottom = 10f,
|
||||
fontSize = 30f,
|
||||
height = 80f,
|
||||
color = new StyleColor(Color.white)
|
||||
}
|
||||
};
|
||||
|
||||
loadBtn.RegisterCallback<ClickEvent>(_ =>
|
||||
{
|
||||
ApplyConfigToUI(preset.Config);
|
||||
ToggleScreens(false);
|
||||
_root.Remove(_presetConfigContainer);
|
||||
_presetConfigContainer = null;
|
||||
});
|
||||
|
||||
var deleteBtn = new Button
|
||||
{
|
||||
text = "삭제",
|
||||
style =
|
||||
{
|
||||
width = 120f,
|
||||
marginTop = 0f,
|
||||
marginBottom = 0f,
|
||||
backgroundColor = new StyleColor(new Color(0.25f, 0.12f, 0.12f, 1.0f)),
|
||||
borderTopColor = new StyleColor(new Color(0.45f, 0.2f, 0.2f, 0.8f)),
|
||||
borderBottomColor = new StyleColor(new Color(0.45f, 0.2f, 0.2f, 0.8f)),
|
||||
borderLeftColor = new StyleColor(new Color(0.45f, 0.2f, 0.2f, 0.8f)),
|
||||
borderRightColor = new StyleColor(new Color(0.45f, 0.2f, 0.2f, 0.8f)),
|
||||
borderTopWidth = 1f,
|
||||
borderBottomWidth = 1f,
|
||||
borderLeftWidth = 1f,
|
||||
borderRightWidth = 1f,
|
||||
borderTopLeftRadius = 8f,
|
||||
borderTopRightRadius = 8f,
|
||||
borderBottomLeftRadius = 8f,
|
||||
borderBottomRightRadius = 8f,
|
||||
paddingLeft = 10f,
|
||||
paddingRight = 10f,
|
||||
paddingTop = 10f,
|
||||
paddingBottom = 10f,
|
||||
fontSize = 30f,
|
||||
height = 80f,
|
||||
color = new StyleColor(Color.white)
|
||||
}
|
||||
};
|
||||
|
||||
deleteBtn.RegisterCallback<ClickEvent>(_ =>
|
||||
{
|
||||
CommonWarningDialogUI.ShowDialog("프리셋 삭제", $"'{preset.Name}' 프리셋을 정말 삭제하시겠습니까?", new DialogButton("예", () =>
|
||||
{
|
||||
PresetManager.DeletePreset(preset.Name);
|
||||
RefreshPresets();
|
||||
}), new DialogButton("아니오", () => { }));
|
||||
});
|
||||
|
||||
btnContainer.Add(loadBtn);
|
||||
btnContainer.Add(deleteBtn);
|
||||
|
||||
itemRow.Add(nameLabel);
|
||||
itemRow.Add(btnContainer);
|
||||
|
||||
scrollView.Add(itemRow);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ToggleScreens(bool showPreset)
|
||||
{
|
||||
if (_root.childCount > 0)
|
||||
|
||||
Reference in new issue
Block a user