Explorar o código

Implements the special guiVariableInspector field type of 'range' which adds a slider to allow editing a float range.

Areloch %!s(int64=5) %!d(string=hai) anos
pai
achega
97880e44dd

+ 4 - 4
Templates/BaseGame/game/core/postFX/scripts/HDRPostFX.cs

@@ -339,10 +339,10 @@ function HDRPostFX::onAdd( %this )
 function HDRPostFX::populatePostFXSettings(%this)
 {
    PostEffectEditorInspector.startGroup("HDR - General");
-   PostEffectEditorInspector.addField("$PostFXManager::Settings::HDR::keyValue", "Key Value", "float", "", $HDRPostFX::keyValue, "");
-   PostEffectEditorInspector.addField("$PostFXManager::Settings::HDR::minLuminace", "Minimum Luminance", "float", "", $HDRPostFX::minLuminace, "");
-   PostEffectEditorInspector.addField("$PostFXManager::Settings::HDR::whiteCutoff", "White Cutoff", "float", "", $HDRPostFX::whiteCutoff, "");
-   PostEffectEditorInspector.addField("$PostFXManager::Settings::HDR::adaptRate", "Brightness Adapt Rate", "float", "", $HDRPostFX::adaptRate, "");
+   PostEffectEditorInspector.addField("$PostFXManager::Settings::HDR::keyValue", "Key Value", "range", "", $HDRPostFX::keyValue, "0 1 10");
+   PostEffectEditorInspector.addField("$PostFXManager::Settings::HDR::minLuminace", "Minimum Luminance", "range", "", $HDRPostFX::minLuminace, "0 1 10");
+   PostEffectEditorInspector.addField("$PostFXManager::Settings::HDR::whiteCutoff", "White Cutoff", "range", "", $HDRPostFX::whiteCutoff, "0 1 10");
+   PostEffectEditorInspector.addField("$PostFXManager::Settings::HDR::adaptRate", "Brightness Adapt Rate", "range", "", $HDRPostFX::adaptRate, "0 1 10");
    PostEffectEditorInspector.endGroup();
    
    PostEffectEditorInspector.startGroup("HDR - Bloom");

+ 144 - 0
Templates/BaseGame/game/tools/gui/fieldTypes/range.cs

@@ -0,0 +1,144 @@
+
+function GuiInspectorVariableGroup::buildRangeField(%this, %fieldName, %fieldLabel, %fieldDesc, %fieldDefaultVal, %fieldDataVals, %callbackName, %ownerObj)
+{
+   %extent = 200;
+   
+   %fieldCtrl = %this.createInspectorField();
+   
+   %extent = %this.stack.getExtent();
+
+   %width = mRound(%extent/2);
+   %height = 20;
+   %inset = 10;
+   
+   %fieldCtrl.setHeightOverride(true, %height);
+   
+   %minRange = getWord(%fieldDataVals,0);
+   %maxRange = getWord(%fieldDataVals,1);
+   %tickCount = getWord(%fieldDataVals,2);
+   %doSnap = getWord(%fieldDataVals,3);
+   
+   if(%doSnap $= "")
+      %doSnap = 0;
+   
+   %editControl = new GuiControl()
+   {
+      class = "guiInspectorRangeField";
+      Position = %fieldCtrl.edit.position;
+      Extent = %fieldCtrl.edit.extent;
+   };
+   
+   %editText = new GuiTextEditCtrl() {
+      class = "guiInspectorRangeFieldText";
+      historySize = "0";
+      tabComplete = "0";
+      sinkAllKeyEvents = "0";
+      password = "0";
+      passwordMask = "*";
+      maxLength = "1024";
+      margin = "0 0 0 0";
+      padding = "0 0 0 0";
+      anchorTop = "1";
+      anchorBottom = "0";
+      anchorLeft = "1";
+      anchorRight = "0";
+      Position = "0 0";
+      Extent = %fieldCtrl.edit.extent.x * 0.2 SPC %fieldCtrl.edit.extent.y;
+      minExtent = "8 2";
+      horizSizing = "right";
+      vertSizing = "bottom";
+      profile = "ToolsGuiTextEditProfile";
+      visible = "1";
+      active = "1";
+      tooltipProfile = "GuiToolTipProfile";
+      hovertime = "1000";
+      isContainer = "1";
+      canSave = "1";
+      canSaveDynamicFields = "0";
+      text = %fieldDefaultVal;
+   };
+   
+   %editSlider = new GuiSliderCtrl() {
+      class = "guiInspectorRangeFieldSlider";
+      range = %minRange SPC %maxRange;
+      ticks = %tickCount;
+      value = %fieldDefaultVal;
+      snap = %doSnap;
+      renderTicks = "true";
+      isContainer = "0";
+      Profile = "GuiSliderProfile";
+      HorizSizing = "width";
+      VertSizing = "bottom";
+      Position = (%fieldCtrl.edit.extent.x * 0.2) + 5 SPC 0;
+      Extent = (%fieldCtrl.edit.extent.x * 0.8) - 5 SPC %fieldCtrl.edit.extent.y;
+      MinExtent = "8 2";
+      canSave = "1";
+      Visible = "1";
+      Command = "$thisControl.onDragComplete();";
+      tooltipprofile = "GuiToolTipProfile";
+      tooltip = %tooltip;
+      hovertime = "1000";
+      canSaveDynamicFields = "0";
+      ownerObject = %ownerObj;
+      fieldName = %fieldName;
+      callbackName = %callbackName;
+   };
+   
+   %editText.sliderControl = %editSlider;
+   %editSlider.textControl = %editText;
+   
+   %editControl.add(%editText);
+   %editControl.add(%editSlider);
+   
+   //set the field value
+   if(getSubStr(%this.fieldName, 0, 1) $= "$")
+   {
+      if(%fieldName $= "")
+         %editControl.setValue(%fieldName);
+   }
+   else if(isObject(%ownerObj))
+   {
+      //regular variable
+      %setCommand = %editControl @ ".setValue(" @ %ownerObj @ "." @ %fieldName @ ");";
+      eval(%setCommand);
+   }
+   
+   %fieldCtrl.setCaption(%fieldLabel);
+   %fieldCtrl.setEditControl(%editControl);
+
+   %this.addInspectorField(%fieldCtrl);
+}
+
+function guiInspectorRangeField::onResize(%this)
+{
+   echo("RESIIIIIIIIIIIZED");  
+}
+
+function guiInspectorRangeFieldText::onReturn(%this)
+{
+   %value = %this.getText();
+   %this.sliderControl.setValue(%value);
+}
+
+function guiInspectorRangeFieldSlider::onDragComplete( %this )
+{   
+   %value = %this.getValue();
+   %this.textControl.setText(%value);
+   
+   if(getSubStr(%this.fieldName, 0, 1) $= "$")
+   {
+      //ah, a global var, just do it straight, then
+      %setCommand = %this.fieldName @ " = \"" @ %value @ "\";";
+   }
+   else if(isObject(%this.ownerObject))
+   {
+      //regular variable
+      %setCommand = %this.ownerObject @ "." @ %this.fieldName @ " = \"" @ %value @ "\";";
+   }
+   else if(%this.callbackName !$= "")
+   {
+      %setCommand = %this.callbackName @ "(\"" @ %this.fieldName @ "\",\"" @ %value @"\");";
+   }
+   
+   eval(%setCommand);
+}

+ 1 - 0
Templates/BaseGame/game/tools/gui/guiDialogs.ed.cs

@@ -40,5 +40,6 @@ exec("./assimpImport.ed.gui");
 exec("./fieldTypes/assetDependencies.cs");
 exec("./fieldTypes/fieldTypes.cs");
 exec("./fieldTypes/listField.cs");
+exec("./fieldTypes/range.cs");
 exec("./fieldTypes/moduleDependencies.cs");
 exec("./fieldTypes/buttonField.cs");