Skip to content

Commit

Permalink
Editor: renamed enum VariableArrayType to GlobalVariableArrayType
Browse files Browse the repository at this point in the history
This is to underline that this is a special description, exclusively for a GlobalVariable object.
  • Loading branch information
ivan-mogilko committed Dec 5, 2024
1 parent 4e44e71 commit 1d01739
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
10 changes: 5 additions & 5 deletions Editor/AGS.Editor/Components/GlobalVariablesComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ private string GenerateGlobalVariablesScriptModule(IList<GlobalVariable> variabl
string declaration = $"{variable.Type} {variable.Name}";
switch (variable.ArrayType)
{
case VariableArrayType.Array:
case GlobalVariableArrayType.Array:
declaration = declaration + $"[{variable.ArraySize}]";
break;
case VariableArrayType.DynamicArray:
case GlobalVariableArrayType.DynamicArray:
declaration = declaration + $"[]";
break;
}
Expand Down Expand Up @@ -103,13 +103,13 @@ private void UpdateScriptHeader()
{
switch (variable.ArrayType)
{
case VariableArrayType.None:
case GlobalVariableArrayType.None:
sb.AppendLine($"import {variable.Type} {variable.Name};");
break;
case VariableArrayType.Array:
case GlobalVariableArrayType.Array:
sb.AppendLine($"import {variable.Type} {variable.Name}[{variable.ArraySize}];");
break;
case VariableArrayType.DynamicArray:
case GlobalVariableArrayType.DynamicArray:
sb.AppendLine($"import {variable.Type} {variable.Name}[];");
break;
}
Expand Down
12 changes: 6 additions & 6 deletions Editor/AGS.Editor/GUI/GlobalVariableDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ private void btnOK_Click(object sender, EventArgs e)
_variable.Name = txtName.Text;
_variable.DefaultValue = txtDefaultValue.Text;
_variable.Type = cmbType.SelectedItem.ToString();
_variable.ArrayType = (VariableArrayType)cmbArray.SelectedIndex;
_variable.ArraySize = _variable.ArrayType == VariableArrayType.Array ? (int)udArraySize.Value : 0;
_variable.ArrayType = (GlobalVariableArrayType)cmbArray.SelectedIndex;
_variable.ArraySize = _variable.ArrayType == GlobalVariableArrayType.Array ? (int)udArraySize.Value : 0;
this.DialogResult = DialogResult.OK;
this.Close();
}
Expand All @@ -115,17 +115,17 @@ private void cmbType_SelectedIndexChanged(object sender, EventArgs e)

private void cmbArray_SelectedIndexChanged(object sender, EventArgs e)
{
VariableArrayType arrType = (VariableArrayType)cmbArray.SelectedIndex;
if (arrType == VariableArrayType.None)
GlobalVariableArrayType arrType = (GlobalVariableArrayType)cmbArray.SelectedIndex;
if (arrType == GlobalVariableArrayType.None)
{
label5.Enabled = false;
udArraySize.Enabled = false;
txtDefaultValue.Enabled = ((GlobalVariableType)cmbType.SelectedItem).CanHaveDefaultValue;
}
else
{
label5.Enabled = arrType == VariableArrayType.Array;
udArraySize.Enabled = arrType == VariableArrayType.Array;
label5.Enabled = arrType == GlobalVariableArrayType.Array;
udArraySize.Enabled = arrType == GlobalVariableArrayType.Array;
// TODO: maybe support array initialization? although it's not convenient to do with a single textbox
txtDefaultValue.Enabled = false;
txtDefaultValue.Text = string.Empty;
Expand Down
4 changes: 2 additions & 2 deletions Editor/AGS.Editor/Panes/GlobalVariablesEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ private void FillListItemFromVariable(ListViewItem item, GlobalVariable variable
string varType;
switch (variable.ArrayType)
{
case VariableArrayType.Array: varType = $"{variable.Type}[{variable.ArraySize}]"; break;
case VariableArrayType.DynamicArray: varType = $"{variable.Type}[]"; break;
case GlobalVariableArrayType.Array: varType = $"{variable.Type}[{variable.ArraySize}]"; break;
case GlobalVariableArrayType.DynamicArray: varType = $"{variable.Type}[]"; break;
default: varType = variable.Type; break;
}

Expand Down
8 changes: 4 additions & 4 deletions Editor/AGS.Types/GlobalVariable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
namespace AGS.Types
{
/// <summary>
/// VariableArrayType provides variable's qualification as an array.
/// GlobalVariableArrayType provides variable's qualification as an array.
/// </summary>
public enum VariableArrayType
public enum GlobalVariableArrayType
{
None, // not an array, regular variable
Array, // static, fixed-sized array
Expand All @@ -20,7 +20,7 @@ public class GlobalVariable
private string _name = string.Empty;
private string _type = string.Empty;
private string _defaultValue = string.Empty;
private VariableArrayType _arrayType = VariableArrayType.None;
private GlobalVariableArrayType _arrayType = GlobalVariableArrayType.None;
private int _arraySize = 0;

public GlobalVariable() { }
Expand All @@ -43,7 +43,7 @@ public string DefaultValue
set { _defaultValue = value; }
}

public VariableArrayType ArrayType
public GlobalVariableArrayType ArrayType
{
get { return _arrayType; }
set { _arrayType = value; }
Expand Down

0 comments on commit 1d01739

Please sign in to comment.