$C = "../Common.ui";
$Sounds = "../Sounds.ui";

@InputLabel = Label {
  Anchor: (Left: 6, Right: 16, Width: 200);
  Style: (...$C.@DefaultLabelStyle, VerticalAlignment: Center, Wrap: true);
};

@MultilineTextField = MultilineTextField {
  Style: $C.@DefaultInputFieldStyle;
  PlaceholderStyle: $C.@DefaultInputFieldPlaceholderStyle;
  Background: $C.@InputBoxBackground;
  AutoGrow: false;
  Padding: (Horizontal: 10, Vertical: 8);
  ScrollbarStyle: $C.@DefaultScrollbarStyle;
};

$C.@PageOverlay #MainPage {
  LayoutMode: Middle;

  $C.@DecoratedContainer {
    Anchor: (Width: 700);

    #Title {
      $C.@Title {
        @Text = %server.customUI.prefabEditorSaveSettings.title;
      }
    }

    #Content {
      LayoutMode: Top;
      Padding: (Full: 16);

      Group #PrefabsToSave {
        LayoutMode: Top;
        Anchor: (Bottom: 16);

        Group {
          LayoutMode: Left;
          Anchor: (Bottom: 8);

          @InputLabel {
            Text: %server.customUI.prefabEditorSaveSettings.prefabsToSave;
          }

          $C.@SecondaryTextButton #BrowseButton {
            @Anchor = (Width: 130, Right: 4);
            Text: %server.customUI.prefabEditorSaveSettings.browse;
          }

          $C.@SecondaryTextButton #SelectAllButton {
            @Anchor = (Width: 90, Right: 4);
            Text: %server.customUI.prefabEditorSaveSettings.selectAll;
          }

          $C.@SecondaryTextButton #SelectEditedButton {
            @Anchor = (Width: 110, Right: 16);
            Text: %server.customUI.prefabEditorSaveSettings.selectEdited;
          }
        }

        @MultilineTextField #Input {
          Anchor: (Height: 80);
          MaxLength: 4096;
          PlaceholderText: %server.customUI.prefabEditorSaveSettings.prefabsToSavePlaceholder;
        }
      }

      Group {
        Anchor: (Vertical: 8, Height: 1);
        Background: #5e512c(0.4);
      }

      Group #Entities {
        LayoutMode: Left;
        Anchor: (Bottom: 16);

        @InputLabel {
          Text: %server.customUI.prefabEditorSaveSettings.saveEntities;
        }

        $C.@CheckBox #CheckBox {
          Value: true;
        }
      }

      Group #Empty {
        LayoutMode: Left;
        Anchor: (Bottom: 16);

        @InputLabel {
          Text: %server.customUI.prefabEditorSaveSettings.includeEmptyBlocks;
        }

        $C.@CheckBox #CheckBox {
          Value: false;
        }
      }

      Group #Overwrite {
        LayoutMode: Left;
        Anchor: (Bottom: 16);

        @InputLabel {
          Text: %server.customUI.prefabEditorSaveSettings.overwriteExisting;
        }

        $C.@CheckBox #CheckBox {
          Value: true;
        }
      }

      Group {
        Anchor: (Vertical: 8, Height: 1);
        Background: #5e512c(0.4);
      }

      Group {
        LayoutMode: Center;
        Anchor: (Top: 8);

        $C.@TextButton #SaveButton {
          @Sounds = $Sounds.@SaveSettings;
          @Anchor = (Right: 4);
          Text: %server.customUI.prefabEditorSaveSettings.save;
          FlexWeight: 1;
        }

        $C.@SecondaryTextButton #CancelButton {
          @Sounds = $Sounds.@ButtonsCancel;
          @Anchor = (Left: 4);
          Text: %server.customUI.cancel;
          FlexWeight: 1;
        }
      }
    }
  }
}

$C.@PageOverlay #BrowserPage {
  LayoutMode: Middle;
  Visible: false;

  $C.@DecoratedContainer {
    Anchor: (Width: 600, Height: 600);

    #Title {
      $C.@Title {
        @Text = %server.customUI.prefabEditorSaveSettings.browser.title;
      }
    }

    #Content {
      LayoutMode: Top;
      Padding: (Full: 16);

      Label {
        Anchor: (Bottom: 8, Horizontal: 4);
        Style: (...$C.@DefaultLabelStyle, FontSize: 12, TextColor: #96a9be);
        Text: %server.customUI.prefabEditorSaveSettings.browser.hint;
      }

      $C.@TextField #SearchInput {
        @Anchor = (Bottom: 10);
        PlaceholderText: %server.customUI.prefabEditorSaveSettings.browser.searchPlaceholder;
      }

      Group #FileList {
        FlexWeight: 1;
        LayoutMode: TopScrolling;
        ScrollbarStyle: $C.@DefaultScrollbarStyle;
      }

      Group #BrowserButtons {
        LayoutMode: Center;
        Anchor: (Top: 12);

        $C.@SecondaryTextButton #SelectAllBrowserButton {
          @Sounds = $Sounds.@SaveSettings;
          @Anchor = (Right: 4);
          Text: %server.customUI.prefabEditorSaveSettings.selectAll;
          FlexWeight: 1;
        }

        $C.@TextButton #ConfirmButton {
          @Sounds = $Sounds.@SaveSettings;
          @Anchor = (Left: 4, Right: 4);
          Text: %server.customUI.prefabEditorSaveSettings.browser.confirm;
          FlexWeight: 1;
        }

        $C.@SecondaryTextButton #CancelButton {
          @Sounds = $Sounds.@ButtonsCancel;
          @Anchor = (Left: 4);
          Text: %server.customUI.cancel;
          FlexWeight: 1;
        }
      }
    }
  }
}

$C.@PageOverlay #SavingPage {
  LayoutMode: Middle;
  Visible: false;

  $C.@DecoratedContainer {
    Anchor: (Width: 450);

    #Title {
      $C.@Title {
        @Text = %server.customUI.prefabEditorSaveSettings.saving.title;
      }
    }

    #Content {
      LayoutMode: Top;
      Padding: (Full: 24);

      Label #StatusText {
        Anchor: (Bottom: 16, Horizontal: 8);
        Style: (...$C.@DefaultLabelStyle, HorizontalAlignment: Center, VerticalAlignment: Center);
        Text: %server.customUI.prefabEditorSaveSettings.saving.initializing;
      }

      Group {
        Anchor: (Height: 12, Bottom: 16, Horizontal: 16);
        Background: "../Common/ProgressBar.png";

        ProgressBar #ProgressBar {
          BarTexturePath: "../Common/ProgressBarFill.png";
          EffectTexturePath: "../Common/ProgressBarEffect.png";
          EffectWidth: 102;
          EffectHeight: 58;
          EffectOffset: 74;
        }
      }

      Label #ErrorText {
        Anchor: (Bottom: 16, Horizontal: 8);
        Visible: false;
        Style: (...$C.@DefaultLabelStyle, HorizontalAlignment: Center, VerticalAlignment: Center, TextColor: #ff6b6b);
        Text: "";
      }

      Group {
        LayoutMode: Center;
        Anchor: (Top: 8);

        $C.@SecondaryTextButton #BackButton {
          @Sounds = $Sounds.@ButtonsCancel;
          Text: %server.customUI.back;
          FlexWeight: 1;
        }
      }
    }
  }
}

$C.@BackButton {}
