public Sphere(ComponentPlayer player, int id, TerrainRaycastResult?Point1, SubsystemTerrain subsystemTerrain) { Point = null; Point = Point1; m_subsystemTerrain = subsystemTerrain; id1 = id; this.player = player; WidgetsManager.LoadWidgetContents(this, this, ContentManager.Get <XElement>("WE/DialogsWE/SphereDialog")); m_title = this.Children.Find <LabelWidget>("Sphere_Dialog.Title", true); Mode = this.Children.Find <LabelWidget>("Sphere_Dialog.Mode", true); Icon_select = this.Children.Find <ButtonWidget>("Sphere_Dialog.Icon_select", true); m_radius = this.Children.Find <SliderWidget>("Sphere_Dialog.Slider1", true); plusButton = this.Children.Find <ButtonWidget>("Sphere_Dialog.Button4", true); minusButton = this.Children.Find <ButtonWidget>("Sphere_Dialog.Button3", true); mSelect_mode = this.Children.Find <ButtonWidget>("Sphere_Dialog.Select_mode", true); m_okButton = this.Children.Find <ButtonWidget>("Sphere_Dialog.OK", true); m_cancelButton = this.Children.Find <ButtonWidget>("Sphere_Dialog.Cancel", true); this.m_blockIconWidget = this.Children.Find <BlockIconWidget>("Sphere_Dialog.Icon", true); m_title.Text = "Sphere"; //switch_mode.Text = "Holow"; //m_blockIconWidget.Value Mode.Text = "Hollow"; m_radius.MinValue = 1f; m_radius.MaxValue = 100; m_radius.Value = 1f; names.Add("Soild"); names.Add("Hollow"); foreach (string category in names) { m_categories.Add(new Category() { Name = category, }); } }
//called when data for any output pin is requested public void Evaluate(int SpreadMax) { FParams.Clear(); for (int i = 0; i < SpreadMax; i++) { Widget widget = null; switch (FWidget[i].ToLower()) { case "bang": widget = new BangWidget(); break; case "press": widget = new PressWidget(); break; case "toggle": widget = new ToggleWidget(); break; case "slider": widget = new SliderWidget(); break; case "endless": widget = new NumberboxWidget(); break; } // var param = new Parameter(FId[i].ToRCPId(), FDatatype[i], FTypeDefinition[i], FValue[i], FLabel[i], new byte[0]{}/*FParent[i].ToRCPId()*/, widget, FUserdata[i]); // FParams.Add(param); } FParameter.AssignFrom(FParams); }
public CylindricalDialog(CreatorAPI creatorAPI) : base(creatorAPI) { this.Children.Find <LabelWidget>("名称", true).Text = "圆柱"; this.Children.Find <StackPanelWidget>("Data3", true).IsVisible = true; this.ZRadius = this.Children.Find <SliderWidget>("滑条3", true); this.zRadiusLabelWidget = this.Children.Find <LabelWidget>("滑条3数据", true); }
void Awake() { DataPanelWidgets p = GetComponent <DataPanelWidgets>(); p.AddHeadTitleWidget("Magnitude"); Listener = p.AddListener(); Frame = p.AddFrame(); //PreferUdp = p.AddToggle("Prefer UDP"); CloseButton = p.AddTrashButton(); HideButton = p.AddHideButton(); ShowAxis = p.AddToggle("Show Frame"); ShowAngle = p.AddToggle("Show Angle"); ShowVector = p.AddToggle("Show Vector"); ShowTrail = p.AddToggle("Show Trail"); Scale = p.AddSlider("Scale (All)").SetMinValue(0.1f).SetMaxValue(10.0f).SetNumberOfSteps(99); VectorColor = p.AddColorPicker("Vector Color"); VectorScale = p.AddSlider("Additional Scale (Vector)").SetMinValue(0.1f).SetMaxValue(10.0f).SetNumberOfSteps(99); ScaleMultiplier = p.AddSlider("Multiply Scale (Vector) by Power of 10").SetMinValue(-4).SetMaxValue(4).SetIntegerOnly(true); p.AddCollapsibleWidget("Vector...") .Attach(VectorColor) .Attach(VectorScale) .Attach(ScaleMultiplier) .UpdateSize(); p.UpdateSize(); gameObject.SetActive(false); }
internal void DrawProgressBox(int progress) { SliderWidget slider = (SliderWidget)widgets[sliderIndex]; slider.Visible = true; slider.Value = progress; slider.Redraw(drawer); }
public SpiralDialog(CreatorAPI creatorAPI) : base(creatorAPI) { this.Children.Find <LabelWidget>("名称", true).Text = "螺旋"; this.Children.Find <StackPanelWidget>("Data3", true).IsVisible = true; this.Number = this.Children.Find <SliderWidget>("滑条3", true); this.numberLabelWidget = this.Children.Find <LabelWidget>("滑条3数据", true); this.SoildButton.Text = "确定"; this.HollowButton.IsVisible = false; }
private void setupListeners() { eventChannel = new EventChannel(CustomizationContext.EventBus); eventChannel.AddListener <CustomizerWidgetEvents.ShowScaleAndRotateWidget>(onShowRotateScaleWidgets); eventChannel.AddListener <CustomizerWidgetEvents.HideScaleAndRotateWidget>(onHideRotateScaleWidgets); eventChannel.AddListener <CustomizerWidgetEvents.SetSliderWidgetValue>(onSetSliderWidgetValue); eventChannel.AddListener <CustomizerWidgetEvents.SetIsSliderWidgetInteractable>(onSetIsSliderWidgetInteractable); sliderWidget = SliderWidget; }
public SliderWidget(SliderWidget other) : base(other) { OnChange = other.OnChange; Ticks = other.Ticks; MinimumValue = other.MinimumValue; MaximumValue = other.MaximumValue; Value = other.Value; TrackHeight = other.TrackHeight; GetValue = other.GetValue; }
public PavageDialog(CreatorAPI creatorAPI) { this.creatorAPI = creatorAPI; this.player = creatorAPI.componentMiner.ComponentPlayer; XElement node = ContentManager.Get <XElement>("NewWidgets/Dialog/平铺界面"); WidgetsManager.LoadWidgetContents(this, this, node); this.OKButton = Children.Find <ButtonWidget>("确定", true); this.cancelButton = Children.Find <ButtonWidget>("取消", true); this.TextBox = Children.Find <TextBoxWidget>("方块ID", true); this.slider = Children.Find <SliderWidget>("滑条1", true); }
public Mountain(ComponentPlayer player, TerrainRaycastResult?Point1, SubsystemTerrain subsystemTerrain) { m_subsystemTerrain = subsystemTerrain; Point = Point1; id1 = 3; id2 = 2; id3 = 8; this.player = player; WidgetsManager.LoadWidgetContents(this, this, ContentManager.Get <XElement>("WE/DialogsWE/MountainDialog")); m_title = this.Children.Find <LabelWidget>("Mountain_Dialog.Title", true); Icon_select = this.Children.Find <ButtonWidget>("Mountain_Dialog.Icon_select", true); Icon_select1 = this.Children.Find <ButtonWidget>("Mountain_Dialog.Icon_select1", true); Icon_select2 = this.Children.Find <ButtonWidget>("Mountain_Dialog.Icon_select2", true); m_radius = this.Children.Find <SliderWidget>("Mountain_Dialog.Slider1", true); m_lenght = this.Children.Find <SliderWidget>("Mountain_Dialog.Slider2", true); plusButton = this.Children.Find <ButtonWidget>("Mountain_Dialog.Button4", true); minusButton = this.Children.Find <ButtonWidget>("Mountain_Dialog.Button3", true); lenght_plusButton = this.Children.Find <ButtonWidget>("Mountain_Dialog.Button2", true); lenght_minusButton = this.Children.Find <ButtonWidget>("Mountain_Dialog.Button1", true); m_okButton = this.Children.Find <ButtonWidget>("Mountain_Dialog.OK", true); m_cancelButton = this.Children.Find <ButtonWidget>("Mountain_Dialog.Cancel", true); m_blockIconWidget = this.Children.Find <BlockIconWidget>("Mountain_Dialog.Icon", true); m_blockIconWidget1 = this.Children.Find <BlockIconWidget>("Mountain_Dialog.Icon1", true); m_blockIconWidget2 = this.Children.Find <BlockIconWidget>("Mountain_Dialog.Icon2", true); m_title.Text = "Mountain"; //switch_mode.Text = "Holow"; //m_blockIconWidget.Value m_radius.MinValue = 1f; m_radius.MaxValue = 100; m_radius.Value = 1f; m_lenght.MinValue = 1f; m_lenght.MaxValue = 100; m_lenght.Value = 1f; }
line_patterns_application(PixelFormats format, AGG.UI.PlatformSupportAbstract.ERenderOrigin RenderOrigin) : base(format, RenderOrigin) { m_ctrl_color = new RGBA_Bytes(0, 0.3, 0.5, 0.3); m_scale_x = new SliderWidget(5.0, 5.0, 240.0, 12.0); m_start_x = new SliderWidget(250.0, 5.0, 495.0, 12.0); m_approximation_method = new cbox_ctrl(10, 30, "Approximation Method = curve_div"); m_curve1.line_color(m_ctrl_color); m_curve2.line_color(m_ctrl_color); m_curve3.line_color(m_ctrl_color); m_curve4.line_color(m_ctrl_color); m_curve5.line_color(m_ctrl_color); m_curve6.line_color(m_ctrl_color); m_curve7.line_color(m_ctrl_color); m_curve8.line_color(m_ctrl_color); m_curve9.line_color(m_ctrl_color); m_curve1.curve(64, 19, 14, 126, 118, 266, 19, 265); m_curve2.curve(112, 113, 178, 32, 200, 132, 125, 438); m_curve3.curve(401, 24, 326, 149, 285, 11, 177, 77); m_curve4.curve(188, 427, 129, 295, 19, 283, 25, 410); m_curve5.curve(451, 346, 302, 218, 265, 441, 459, 400); m_curve6.curve(454, 198, 14, 13, 220, 291, 483, 283); m_curve7.curve(301, 398, 355, 231, 209, 211, 170, 353); m_curve8.curve(484, 101, 222, 33, 486, 435, 487, 138); m_curve9.curve(143, 147, 11, 45, 83, 427, 132, 197); AddChild(m_curve1); AddChild(m_curve2); AddChild(m_curve3); AddChild(m_curve4); AddChild(m_curve5); AddChild(m_curve6); AddChild(m_curve7); AddChild(m_curve8); AddChild(m_curve9); AddChild(m_approximation_method); m_scale_x.label("Scale X=%.2f"); m_scale_x.range(0.2, 3.0); m_scale_x.value(1.0); AddChild(m_scale_x); m_start_x.label("Start X=%.2f"); m_start_x.range(0.0, 10.0); m_start_x.value(0.0); AddChild(m_start_x); }
public EditWorldDialog(CreatorAPI creatorAPI) { this.creatorAPI = creatorAPI; this.player = creatorAPI.componentMiner.ComponentPlayer; XElement node = ContentManager.Get <XElement>("NewWidgets/Dialog/编辑世界"); WidgetsManager.LoadWidgetContents(this, this, node); this.worldSettings = player.Project.FindSubsystem <SubsystemGameInfo>(true).WorldSettings; this.OKButton = Children.Find <ButtonWidget>("确定"); this.UpdataWorldButton = Children.Find <ButtonWidget>("重载"); this.UpdataButton = Children.Find <ButtonWidget>("刷新"); this.paletteButton = this.Children.Find <ButtonWidget>("Palette", true); this.blocksTextureIcon = this.Children.Find <RectangleWidget>("BlocksTextureIcon", true); this.blocksTextureLabel = this.Children.Find <LabelWidget>("BlocksTextureLabel", true); this.blocksTextureDetails = this.Children.Find <LabelWidget>("BlocksTextureDetails", true); this.blocksTextureButton = this.Children.Find <ButtonWidget>("BlocksTextureButton", true); this.supernaturalCreaturesButton = this.Children.Find <ButtonWidget>("SupernaturalCreatures", true); this.environmentBehaviorButton = this.Children.Find <ButtonWidget>("EnvironmentBehavior", true); this.timeOfDayButton = this.Children.Find <ButtonWidget>("TimeOfDay", true); this.weatherEffectsButton = this.Children.Find <ButtonWidget>("WeatherEffects", true); this.adventureRespawnButton = this.Children.Find <ButtonWidget>("AdventureRespawn", true); this.adventureSurvivalMechanicsButton = this.Children.Find <ButtonWidget>("AdventureSurvivalMechanics", true); this.terrainGenerationLabel = this.Children.Find <LabelWidget>("TerrainGenerationLabel", true); this.terrainGenerationButton = this.Children.Find <ButtonWidget>("TerrainGeneration", true); this.seaLevelOffsetSlider = this.Children.Find <SliderWidget>("SeaLevelOffset", true); this.temperatureOffsetSlider = this.Children.Find <SliderWidget>("TemperatureOffset", true); this.humidityOffsetSlider = this.Children.Find <SliderWidget>("HumidityOffset", true); this.biomeSizeSlider = this.Children.Find <SliderWidget>("BiomeSize", true); this.islandTerrainPanel = this.Children.Find <Widget>("IslandTerrainPanel", true); this.islandSizeNS = this.Children.Find <SliderWidget>("IslandSizeNS", true); this.islandSizeEW = this.Children.Find <SliderWidget>("IslandSizeEW", true); this.flatTerrainPanel = this.Children.Find <Widget>("FlatTerrainPanel", true); this.continentTerrainPanel = this.Children.Find <Widget>("ContinentTerrainPanel", true); this.flatTerrainLevelSlider = this.Children.Find <SliderWidget>("FlatTerrainLevel", true); this.flatTerrainBlock = this.Children.Find <BlockIconWidget>("FlatTerrainBlock", true); this.flatTerrainBlockLabel = this.Children.Find <LabelWidget>("FlatTerrainBlockLabel", true); this.flatTerrainBlockButton = this.Children.Find <ButtonWidget>("FlatTerrainBlockButton", true); this.flatTerrainMagmaOceanCheckbox = this.Children.Find <CheckboxWidget>("MagmaOcean", true); this.islandSizeEW.MinValue = 0f; this.islandSizeEW.MaxValue = (float)(this.islandSizes.Length - 1); this.islandSizeEW.Granularity = 1f; this.islandSizeNS.MinValue = 0f; this.islandSizeNS.MaxValue = (float)(this.islandSizes.Length - 1); this.islandSizeNS.Granularity = 1f; this.biomeSizeSlider.MinValue = 0f; this.biomeSizeSlider.MaxValue = (float)(this.biomeSizes.Length - 1); this.biomeSizeSlider.Granularity = 1f; }
public LevelSetDialog(CreatorAPI creatorAPI) { this.player = creatorAPI.componentMiner.ComponentPlayer; XElement node = ContentManager.Get <XElement>("NewWidgets/Dialog/等级设置"); WidgetsManager.LoadWidgetContents(this, this, node); this.Radius = Children.Find <SliderWidget>("等级", true); this.plusButton = Children.Find <ButtonWidget>("增加按钮", true); this.minusButton = Children.Find <ButtonWidget>("减少按钮", true); this.delayLabel = Children.Find <LabelWidget>("滑条", true); this.OK = Children.Find <ButtonWidget>("确定", true); this.Cancel = Children.Find <ButtonWidget>("取消", true); this.Radius.Value = player.PlayerData.Level; this.UpdateControls(); }
public EditRegionDialog(CreatorAPI creatorAPI) { this.creatorAPI = creatorAPI; this.player = creatorAPI.componentMiner.ComponentPlayer; this.subsystemTerrain = creatorAPI.componentMiner.Project.FindSubsystem <SubsystemTerrain>(true); XElement node = ContentManager.Get <XElement>("NewWidgets/Dialog/编辑区域"); WidgetsManager.LoadWidgetContents(this, this, node); this.SliderData = this.Children.Find <LabelWidget>("滑条数据", true); this.TemperatureSlider = this.Children.Find <SliderWidget>("滑条1", true); this.HumiditySlider = this.Children.Find <SliderWidget>("滑条2", true); this.TopHeightSlider = this.Children.Find <SliderWidget>("滑条3", true); this.OKButton = this.Children.Find <ButtonWidget>("确定", true); this.cancelButton = this.Children.Find <ButtonWidget>("取消"); }
public PyramidDialog(CreatorAPI creatorAPI) : base(creatorAPI) { this.creatorAPI = creatorAPI; this.player = creatorAPI.componentMiner.ComponentPlayer; this.subsystemTerrain = player.Project.FindSubsystem <SubsystemTerrain>(true); XElement node = ContentManager.Get <XElement>("NewWidgets/Dialog/棱体棱锥界面"); WidgetsManager.LoadWidgetContents(this, this, node); base.GeneralSet(); this.Children.Find <StackPanelWidget>("XYZ", true).IsVisible = false; this.Children.Find <LabelWidget>("名称", true).Text = "棱锥"; this.Radius = this.Children.Find <SliderWidget>("滑条", true); this.delayLabel = this.Children.Find <LabelWidget>("滑条数据", true); this.SoildButton = this.Children.Find <ButtonWidget>("实心", true); this.HollowButton = this.Children.Find <ButtonWidget>("空心", true); }
public PillarsDialog(CreatorAPI creatorAPI) : base(creatorAPI) { XElement node = ContentManager.Get <XElement>("NewWidgets/Dialog/柱子界面"); WidgetsManager.LoadWidgetContents(this, this, node); base.GeneralSet(); base.setShaftXYZ(); Y_Shaft.Text = "正Y轴"; this.Children.Find <LabelWidget>("名称", true).Text = "柱子"; this.Radius = this.Children.Find <SliderWidget>("滑条1", true); this.radiusDelayLabel = this.Children.Find <LabelWidget>("滑条1数据", true); this.Height = this.Children.Find <SliderWidget>("滑条2", true); this.heightDelayLabel = this.Children.Find <LabelWidget>("滑条2数据", true); this.Children.Find <StackPanelWidget>("Data3", true).IsVisible = false; this.SoildButton = this.Children.Find <ButtonWidget>("实心", true); this.HollowButton = this.Children.Find <ButtonWidget>("空心", true); }
public SphereDialog(CreatorAPI creatorAPI) : base(creatorAPI) { XElement node = ContentManager.Get <XElement>("NewWidgets/Dialog/球体界面"); WidgetsManager.LoadWidgetContents(this, this, node); base.GeneralSet(); this.XRadius = this.Children.Find <SliderWidget>("X半径滑条", true); this.YRadius = this.Children.Find <SliderWidget>("Y半径滑条", true); this.ZRadius = this.Children.Find <SliderWidget>("Z半径滑条", true); this.XdelayLabel = this.Children.Find <LabelWidget>("X半径", true); this.YdelayLabel = this.Children.Find <LabelWidget>("Y半径", true); this.ZdelayLabel = this.Children.Find <LabelWidget>("Z半径", true); this.SoildButton = this.Children.Find <ButtonWidget>("实心", true); this.HollowButton = this.Children.Find <ButtonWidget>("空心", true); this.AdvancedButton = this.Children.Find <ButtonWidget>("高级"); this.AdvancedGenerate = this.Children.Find <Widget>("高级生成"); this.DoublePositionButton = this.Children.Find <ButtonWidget>("2点模式"); }
public MountainDialog(CreatorAPI creatorAPI) { this.creatorAPI = creatorAPI; this.player = creatorAPI.componentMiner.ComponentPlayer; XElement node = ContentManager.Get <XElement>("NewWidgets/Dialog/山脉界面"); WidgetsManager.LoadWidgetContents(this, this, node); this.OK = Children.Find <ButtonWidget>("确定", true); this.cancelButton = Children.Find <ButtonWidget>("取消", true); this.num_1 = Children.Find <LabelWidget>("滑条1数据", true); this.num_2 = Children.Find <LabelWidget>("滑条2数据", true); this.num_3 = Children.Find <LabelWidget>("滑条3数据", true); this.TextBox = Children.Find <TextBoxWidget>("方块ID", true); this.num1 = Children.Find <SliderWidget>("滑条1", true); this.num2 = Children.Find <SliderWidget>("滑条2", true); this.num3 = Children.Find <SliderWidget>("滑条3", true); num3.Value = 100f; this.restting = Children.Find <ButtonWidget>("重置", true); }
protected override void MouseMove(int x, int y, int xDelta, int yDelta) { base.MouseMove(x, y, xDelta, yDelta); for (int i = 0; i < 3; i++) { SliderWidget slider = (SliderWidget)widgets[view.sliderIndex + i]; if (x < slider.X || y < slider.Y || x >= slider.X + slider.Width || y >= slider.Y + slider.Height) { continue; } int value = x - slider.X; // Map from 0 to 255 value = (255 * value) / (slider.Width - 1); slider.Value = value; RedrawWidget(slider); return; } }
public FastRun(ComponentPlayer player) { this.player = player; WidgetsManager.LoadWidgetContents(this, this, ContentManager.Get <XElement>("WE/DialogsWE/FastRunDialog")); m_title = this.Children.Find <LabelWidget>("Dialog.Title", true); m_speed = this.Children.Find <SliderWidget>("Dialog.Slider1", true); plusButton = this.Children.Find <ButtonWidget>("Dialog.Button4", true); minusButton = this.Children.Find <ButtonWidget>("Dialog.Button3", true); m_okButton = this.Children.Find <ButtonWidget>("Dialog.OK", true); m_cancelButton = this.Children.Find <ButtonWidget>("Dialog.Cancel", true); m_speed.MinValue = 0f; m_speed.MaxValue = 100; m_speed.Value = ComponentWE5.speed; m_title.Text = "FastRun"; }
public AssetBrowserLogic(Widget widget, Action onExit, ModData modData, World world, Dictionary <string, MiniYaml> logicArgs) { this.world = world; this.modData = modData; panel = widget; var ticker = panel.GetOrNull <LogicTickerWidget>("ANIMATION_TICKER"); if (ticker != null) { ticker.OnTick = () => { if (animateFrames) { SelectNextFrame(); } }; } var sourceDropdown = panel.GetOrNull <DropDownButtonWidget>("SOURCE_SELECTOR"); if (sourceDropdown != null) { sourceDropdown.OnMouseDown = _ => ShowSourceDropdown(sourceDropdown); var sourceName = new CachedTransform <IReadOnlyPackage, string>(GetSourceDisplayName); sourceDropdown.GetText = () => sourceName.Update(assetSource); } var spriteWidget = panel.GetOrNull <SpriteWidget>("SPRITE"); if (spriteWidget != null) { spriteWidget.GetSprite = () => currentSprites != null ? currentSprites[currentFrame] : null; currentPalette = spriteWidget.Palette; spriteWidget.GetPalette = () => currentPalette; spriteWidget.IsVisible = () => !isVideoLoaded && !isLoadError && currentSprites != null; } var playerWidget = panel.GetOrNull <VqaPlayerWidget>("PLAYER"); if (playerWidget != null) { playerWidget.IsVisible = () => isVideoLoaded && !isLoadError; } var modelWidget = panel.GetOrNull <ModelWidget>("VOXEL"); if (modelWidget != null) { modelWidget.GetVoxel = () => currentVoxel; currentPalette = modelWidget.Palette; modelWidget.GetPalette = () => currentPalette; modelWidget.GetPlayerPalette = () => currentPalette; modelWidget.GetRotation = () => modelOrientation; modelWidget.IsVisible = () => !isVideoLoaded && !isLoadError && currentVoxel != null; } var errorLabelWidget = panel.GetOrNull("ERROR"); if (errorLabelWidget != null) { errorLabelWidget.IsVisible = () => isLoadError; } var paletteDropDown = panel.GetOrNull <DropDownButtonWidget>("PALETTE_SELECTOR"); if (paletteDropDown != null) { paletteDropDown.OnMouseDown = _ => ShowPaletteDropdown(paletteDropDown, world); paletteDropDown.GetText = () => currentPalette; } var colorPreview = panel.GetOrNull <ColorPreviewManagerWidget>("COLOR_MANAGER"); if (colorPreview != null) { colorPreview.Color = Game.Settings.Player.Color; } var colorDropdown = panel.GetOrNull <DropDownButtonWidget>("COLOR"); if (colorDropdown != null) { colorDropdown.IsDisabled = () => currentPalette != colorPreview.PaletteName; colorDropdown.OnMouseDown = _ => ColorPickerLogic.ShowColorDropDown(colorDropdown, colorPreview, world); panel.Get <ColorBlockWidget>("COLORBLOCK").GetColor = () => Game.Settings.Player.Color; } filenameInput = panel.Get <TextFieldWidget>("FILENAME_INPUT"); filenameInput.OnTextEdited = () => ApplyFilter(); filenameInput.OnEscKey = filenameInput.YieldKeyboardFocus; var frameContainer = panel.GetOrNull("FRAME_SELECTOR"); if (frameContainer != null) { frameContainer.IsVisible = () => (currentSprites != null && currentSprites.Length > 1) || (isVideoLoaded && player != null && player.Video != null && player.Video.Frames > 1); } frameSlider = panel.GetOrNull <SliderWidget>("FRAME_SLIDER"); if (frameSlider != null) { frameSlider.OnChange += x => { if (!isVideoLoaded) { currentFrame = (int)Math.Round(x); } }; frameSlider.GetValue = () => isVideoLoaded ? player.Video.CurrentFrame : currentFrame; frameSlider.IsDisabled = () => isVideoLoaded; } var frameText = panel.GetOrNull <LabelWidget>("FRAME_COUNT"); if (frameText != null) { frameText.GetText = () => isVideoLoaded ? "{0} / {1}".F(player.Video.CurrentFrame + 1, player.Video.Frames) : "{0} / {1}".F(currentFrame, currentSprites.Length - 1); } var playButton = panel.GetOrNull <ButtonWidget>("BUTTON_PLAY"); if (playButton != null) { playButton.OnClick = () => { if (isVideoLoaded) { player.Play(); } else { animateFrames = true; } }; playButton.IsVisible = () => isVideoLoaded ? player.Paused : !animateFrames; } var pauseButton = panel.GetOrNull <ButtonWidget>("BUTTON_PAUSE"); if (pauseButton != null) { pauseButton.OnClick = () => { if (isVideoLoaded) { player.Pause(); } else { animateFrames = false; } }; pauseButton.IsVisible = () => isVideoLoaded ? !player.Paused : animateFrames; } var stopButton = panel.GetOrNull <ButtonWidget>("BUTTON_STOP"); if (stopButton != null) { stopButton.OnClick = () => { if (isVideoLoaded) { player.Stop(); } else { if (frameSlider != null) { frameSlider.Value = 0; } currentFrame = 0; animateFrames = false; } }; } var nextButton = panel.GetOrNull <ButtonWidget>("BUTTON_NEXT"); if (nextButton != null) { nextButton.OnClick = () => { if (!isVideoLoaded) { nextButton.OnClick = SelectNextFrame; } }; nextButton.IsVisible = () => !isVideoLoaded; } var prevButton = panel.GetOrNull <ButtonWidget>("BUTTON_PREV"); if (prevButton != null) { prevButton.OnClick = () => { if (!isVideoLoaded) { SelectPreviousFrame(); } }; prevButton.IsVisible = () => !isVideoLoaded; } var voxelContainer = panel.GetOrNull("VOXEL_SELECTOR"); if (voxelContainer != null) { voxelContainer.IsVisible = () => currentVoxel != null; } var rollSlider = panel.GetOrNull <SliderWidget>("ROLL_SLIDER"); if (rollSlider != null) { rollSlider.OnChange += x => { var roll = (int)x; modelOrientation = modelOrientation.WithRoll(new WAngle(roll)); }; rollSlider.GetValue = () => modelOrientation.Roll.Angle; } var pitchSlider = panel.GetOrNull <SliderWidget>("PITCH_SLIDER"); if (pitchSlider != null) { pitchSlider.OnChange += x => { var pitch = (int)x; modelOrientation = modelOrientation.WithPitch(new WAngle(pitch)); }; pitchSlider.GetValue = () => modelOrientation.Pitch.Angle; } var yawSlider = panel.GetOrNull <SliderWidget>("YAW_SLIDER"); if (yawSlider != null) { yawSlider.OnChange += x => { var yaw = (int)x; modelOrientation = modelOrientation.WithYaw(new WAngle(yaw)); }; yawSlider.GetValue = () => modelOrientation.Yaw.Angle; } var assetBrowserModData = modData.Manifest.Get <AssetBrowser>(); allowedExtensions = assetBrowserModData.SupportedExtensions; acceptablePackages = modData.ModFiles.MountedPackages.Where(p => p.Contents.Any(c => allowedExtensions.Contains(Path.GetExtension(c).ToLowerInvariant()))); assetList = panel.Get <ScrollPanelWidget>("ASSET_LIST"); template = panel.Get <ScrollItemWidget>("ASSET_TEMPLATE"); PopulateAssetList(); var closeButton = panel.GetOrNull <ButtonWidget>("CLOSE_BUTTON"); if (closeButton != null) { closeButton.OnClick = () => { if (isVideoLoaded) { player.Stop(); } Ui.CloseWindow(); onExit(); } } ; } void SelectNextFrame() { currentFrame++; if (currentFrame >= currentSprites.Length) { currentFrame = 0; } } void SelectPreviousFrame() { currentFrame--; if (currentFrame < 0) { currentFrame = currentSprites.Length - 1; } } Dictionary <string, bool> assetVisByName = new Dictionary <string, bool>(); bool FilterAsset(string filename) { var filter = filenameInput.Text; if (string.IsNullOrWhiteSpace(filter)) { return(true); } if (filename.IndexOf(filter, StringComparison.OrdinalIgnoreCase) >= 0) { return(true); } return(false); } void ApplyFilter() { assetVisByName.Clear(); assetList.Layout.AdjustChildren(); assetList.ScrollToTop(); // Select the first visible var firstVisible = assetVisByName.FirstOrDefault(kvp => kvp.Value); if (firstVisible.Key != null && modData.DefaultFileSystem.TryGetPackageContaining(firstVisible.Key, out var package, out var filename)) { LoadAsset(package, filename); } } void AddAsset(ScrollPanelWidget list, string filepath, IReadOnlyPackage package, ScrollItemWidget template) { var item = ScrollItemWidget.Setup(template, () => currentFilename == filepath && currentPackage == package, () => { LoadAsset(package, filepath); }); var label = item.Get <LabelWithTooltipWidget>("TITLE"); WidgetUtils.TruncateLabelToTooltip(label, filepath); item.IsVisible = () => { if (assetVisByName.TryGetValue(filepath, out var visible)) { return(visible); } visible = FilterAsset(filepath); assetVisByName.Add(filepath, visible); return(visible); }; list.AddChild(item); } bool LoadAsset(IReadOnlyPackage package, string filename) { if (isVideoLoaded) { player.Stop(); player = null; isVideoLoaded = false; } if (string.IsNullOrEmpty(filename)) { return(false); } if (!package.Contains(filename)) { return(false); } isLoadError = false; try { currentPackage = package; currentFilename = filename; var prefix = ""; var fs = modData.DefaultFileSystem as OpenRA.FileSystem.FileSystem; if (fs != null) { prefix = fs.GetPrefix(package); if (prefix != null) { prefix += "|"; } } if (Path.GetExtension(filename.ToLowerInvariant()) == ".vqa") { player = panel.Get <VqaPlayerWidget>("PLAYER"); player.Load(prefix + filename); player.DrawOverlay = false; isVideoLoaded = true; if (frameSlider != null) { frameSlider.MaximumValue = (float)player.Video.Frames - 1; frameSlider.Ticks = 0; } return(true); } if (Path.GetExtension(filename.ToLowerInvariant()) == ".vxl") { var voxelName = Path.GetFileNameWithoutExtension(filename); currentVoxel = world.ModelCache.GetModel(voxelName); currentSprites = null; } else { currentSprites = world.Map.Rules.Sequences.SpriteCache[prefix + filename]; currentFrame = 0; if (frameSlider != null) { frameSlider.MaximumValue = (float)currentSprites.Length - 1; frameSlider.Ticks = currentSprites.Length; } currentVoxel = null; } } catch (Exception ex) { isLoadError = true; Log.AddChannel("assetbrowser", "assetbrowser.log"); Log.Write("assetbrowser", "Error reading {0}:{3} {1}{3}{2}", filename, ex.Message, ex.StackTrace, Environment.NewLine); return(false); } return(true); } bool ShowSourceDropdown(DropDownButtonWidget dropdown) { var sourceName = new CachedTransform <IReadOnlyPackage, string>(GetSourceDisplayName); Func <IReadOnlyPackage, ScrollItemWidget, ScrollItemWidget> setupItem = (source, itemTemplate) => { var item = ScrollItemWidget.Setup(itemTemplate, () => assetSource == source, () => { assetSource = source; PopulateAssetList(); }); item.Get <LabelWidget>("LABEL").GetText = () => sourceName.Update(source); return(item); }; var sources = new[] { (IReadOnlyPackage)null }.Concat(acceptablePackages); dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 280, sources, setupItem); return(true); } void PopulateAssetList() { assetList.RemoveChildren(); var files = new SortedList <string, List <IReadOnlyPackage> >(); if (assetSource != null) { foreach (var content in assetSource.Contents) { files.Add(content, new List <IReadOnlyPackage> { assetSource }); } } else { foreach (var mountedPackage in modData.ModFiles.MountedPackages) { foreach (var content in mountedPackage.Contents) { if (!files.ContainsKey(content)) { files.Add(content, new List <IReadOnlyPackage> { mountedPackage }); } else { files[content].Add(mountedPackage); } } } } foreach (var file in files.OrderBy(s => s.Key)) { if (!allowedExtensions.Any(ext => file.Key.EndsWith(ext, true, CultureInfo.InvariantCulture))) { continue; } foreach (var package in file.Value) { AddAsset(assetList, file.Key, package, template); } } } bool ShowPaletteDropdown(DropDownButtonWidget dropdown, World world) { Func <string, ScrollItemWidget, ScrollItemWidget> setupItem = (name, itemTemplate) => { var item = ScrollItemWidget.Setup(itemTemplate, () => currentPalette == name, () => currentPalette = name); item.Get <LabelWidget>("LABEL").GetText = () => name; return(item); }; var palettes = world.WorldActor.TraitsImplementing <IProvidesAssetBrowserPalettes>() .SelectMany(p => p.PaletteNames); dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 280, palettes, setupItem); return(true); } string GetSourceDisplayName(IReadOnlyPackage source) { if (source == null) { return("All Packages"); } // Packages that are explicitly mounted in the filesystem use their explicit mount name var fs = (OpenRA.FileSystem.FileSystem)modData.DefaultFileSystem; var name = fs.GetPrefix(source); // Fall back to the path relative to the mod, engine, or support dir if (name == null) { name = source.Name; var compare = Platform.CurrentPlatform == PlatformType.Windows ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal; if (name.StartsWith(modData.Manifest.Package.Name, compare)) { name = "$" + modData.Manifest.Id + "/" + name.Substring(modData.Manifest.Package.Name.Length + 1); } else if (name.StartsWith(Platform.EngineDir, compare)) { name = "./" + name.Substring(Platform.EngineDir.Length); } else if (name.StartsWith(Platform.SupportDir, compare)) { name = "^" + name.Substring(Platform.SupportDir.Length); } } if (name.Length > 18) { name = "..." + name.Substring(name.Length - 15); } return(name); } }
public Round(ComponentPlayer player, int id, TerrainRaycastResult?Point1, SubsystemTerrain subsystemTerrain) { m_subsystemTerrain = subsystemTerrain; Point = Point1; id1 = id; this.player = player; WidgetsManager.LoadWidgetContents(this, this, ContentManager.Get <XElement>("WE/DialogsWE/RoundDialog")); m_title = this.Children.Find <LabelWidget>("Round_Dialog.Title", true); Mode = this.Children.Find <LabelWidget>("Round_Dialog.Mode", true); mPosition = this.Children.Find <LabelWidget>("Round_Dialog.Pos", true); Icon_select = this.Children.Find <ButtonWidget>("Round_Dialog.Icon_select", true); mselect_pos = this.Children.Find <ButtonWidget>("Round_Dialog.Select_pos", true); m_radius = this.Children.Find <SliderWidget>("Round_Dialog.Slider1", true); m_lenght = this.Children.Find <SliderWidget>("Round_Dialog.Slider2", true); plusButton = this.Children.Find <ButtonWidget>("Round_Dialog.Button4", true); minusButton = this.Children.Find <ButtonWidget>("Round_Dialog.Button3", true); lenght_plusButton = this.Children.Find <ButtonWidget>("Round_Dialog.Button2", true); lenght_minusButton = this.Children.Find <ButtonWidget>("Round_Dialog.Button1", true); mSelect_mode = this.Children.Find <ButtonWidget>("Round_Dialog.Select_mode", true); m_okButton = this.Children.Find <ButtonWidget>("Round_Dialog.OK", true); m_cancelButton = this.Children.Find <ButtonWidget>("Round_Dialog.Cancel", true); this.m_blockIconWidget = this.Children.Find <BlockIconWidget>("Round_Dialog.Icon", true); m_title.Text = "Round"; //switch_mode.Text = "Holow"; //m_blockIconWidget.Value mPosition.Text = "Flat"; Mode.Text = "Hollow"; m_radius.MinValue = 1f; m_radius.MaxValue = 100; m_radius.Value = 1f; m_lenght.MinValue = 1f; m_lenght.MaxValue = 100; m_lenght.Value = 1f; m_blockIconWidget.Value = id; names.Add("Soild"); names.Add("Hollow"); names_pos.Add("Flat"); names_pos.Add("Pos_X"); names_pos.Add("Pos_Y"); foreach (string category in names) { m_categories.Add(new Category() { Name = category, }); } foreach (string category in names_pos) { m_categories_pos.Add(new Category() { Name = category, }); } }
public AssetBrowserLogic(Widget widget, Action onExit, ModData modData, World world, Dictionary <string, MiniYaml> logicArgs) { this.world = world; this.modData = modData; panel = widget; var ticker = panel.GetOrNull <LogicTickerWidget>("ANIMATION_TICKER"); if (ticker != null) { ticker.OnTick = () => { if (animateFrames) { SelectNextFrame(); } }; } var sourceDropdown = panel.GetOrNull <DropDownButtonWidget>("SOURCE_SELECTOR"); if (sourceDropdown != null) { sourceDropdown.OnMouseDown = _ => ShowSourceDropdown(sourceDropdown); sourceDropdown.GetText = () => { var name = assetSource != null?Platform.UnresolvePath(assetSource.Name) : "All Packages"; if (name.Length > 15) { name = "..." + name.Substring(name.Length - 15); } return(name); }; } var spriteWidget = panel.GetOrNull <SpriteWidget>("SPRITE"); if (spriteWidget != null) { spriteWidget.GetSprite = () => currentSprites != null ? currentSprites[currentFrame] : null; currentPalette = spriteWidget.Palette; spriteWidget.GetPalette = () => currentPalette; spriteWidget.IsVisible = () => !isVideoLoaded; } var playerWidget = panel.GetOrNull <VqaPlayerWidget>("PLAYER"); if (playerWidget != null) { playerWidget.IsVisible = () => isVideoLoaded; } var paletteDropDown = panel.GetOrNull <DropDownButtonWidget>("PALETTE_SELECTOR"); if (paletteDropDown != null) { paletteDropDown.OnMouseDown = _ => ShowPaletteDropdown(paletteDropDown, world); paletteDropDown.GetText = () => currentPalette; } var colorPreview = panel.GetOrNull <ColorPreviewManagerWidget>("COLOR_MANAGER"); if (colorPreview != null) { colorPreview.Color = Game.Settings.Player.Color; } var colorDropdown = panel.GetOrNull <DropDownButtonWidget>("COLOR"); if (colorDropdown != null) { colorDropdown.IsDisabled = () => currentPalette != colorPreview.PaletteName; colorDropdown.OnMouseDown = _ => ColorPickerLogic.ShowColorDropDown(colorDropdown, colorPreview, world); panel.Get <ColorBlockWidget>("COLORBLOCK").GetColor = () => Game.Settings.Player.Color.RGB; } filenameInput = panel.Get <TextFieldWidget>("FILENAME_INPUT"); filenameInput.OnTextEdited = () => ApplyFilter(filenameInput.Text); filenameInput.OnEscKey = filenameInput.YieldKeyboardFocus; var frameContainer = panel.GetOrNull("FRAME_SELECTOR"); if (frameContainer != null) { frameContainer.IsVisible = () => (currentSprites != null && currentSprites.Length > 1) || (isVideoLoaded && player != null && player.Video != null && player.Video.Frames > 1); } frameSlider = panel.Get <SliderWidget>("FRAME_SLIDER"); if (frameSlider != null) { frameSlider.OnChange += x => { if (!isVideoLoaded) { currentFrame = (int)Math.Round(x); } }; frameSlider.GetValue = () => isVideoLoaded ? player.Video.CurrentFrame : currentFrame; frameSlider.IsDisabled = () => isVideoLoaded; } var frameText = panel.GetOrNull <LabelWidget>("FRAME_COUNT"); if (frameText != null) { frameText.GetText = () => isVideoLoaded ? "{0} / {1}".F(player.Video.CurrentFrame + 1, player.Video.Frames) : "{0} / {1}".F(currentFrame, currentSprites.Length - 1); } var playButton = panel.GetOrNull <ButtonWidget>("BUTTON_PLAY"); if (playButton != null) { playButton.Key = new Hotkey(Keycode.SPACE, Modifiers.None); playButton.OnClick = () => { if (isVideoLoaded) { player.Play(); } else { animateFrames = true; } }; playButton.IsVisible = () => isVideoLoaded ? player.Paused : !animateFrames; } var pauseButton = panel.GetOrNull <ButtonWidget>("BUTTON_PAUSE"); if (pauseButton != null) { pauseButton.Key = new Hotkey(Keycode.SPACE, Modifiers.None); pauseButton.OnClick = () => { if (isVideoLoaded) { player.Pause(); } else { animateFrames = false; } }; pauseButton.IsVisible = () => isVideoLoaded ? !player.Paused : animateFrames; } var stopButton = panel.GetOrNull <ButtonWidget>("BUTTON_STOP"); if (stopButton != null) { stopButton.Key = new Hotkey(Keycode.RETURN, Modifiers.None); stopButton.OnClick = () => { if (isVideoLoaded) { player.Stop(); } else { frameSlider.Value = 0; currentFrame = 0; animateFrames = false; } }; } var nextButton = panel.GetOrNull <ButtonWidget>("BUTTON_NEXT"); if (nextButton != null) { nextButton.Key = new Hotkey(Keycode.RIGHT, Modifiers.None); nextButton.OnClick = () => { if (!isVideoLoaded) { nextButton.OnClick = SelectNextFrame; } }; nextButton.IsVisible = () => !isVideoLoaded; } var prevButton = panel.GetOrNull <ButtonWidget>("BUTTON_PREV"); if (prevButton != null) { prevButton.Key = new Hotkey(Keycode.LEFT, Modifiers.None); prevButton.OnClick = () => { if (!isVideoLoaded) { SelectPreviousFrame(); } }; prevButton.IsVisible = () => !isVideoLoaded; } if (logicArgs.ContainsKey("SupportedFormats")) { allowedExtensions = FieldLoader.GetValue <string[]>("SupportedFormats", logicArgs["SupportedFormats"].Value); } else { allowedExtensions = new string[0]; } acceptablePackages = modData.ModFiles.MountedPackages.Where(p => p.Contents.Any(c => allowedExtensions.Contains(Path.GetExtension(c).ToLowerInvariant()))); assetList = panel.Get <ScrollPanelWidget>("ASSET_LIST"); template = panel.Get <ScrollItemWidget>("ASSET_TEMPLATE"); PopulateAssetList(); var closeButton = panel.GetOrNull <ButtonWidget>("CLOSE_BUTTON"); if (closeButton != null) { closeButton.OnClick = () => { if (isVideoLoaded) { player.Stop(); } Ui.CloseWindow(); onExit(); } } ; } void SelectNextFrame() { currentFrame++; if (currentFrame >= currentSprites.Length) { currentFrame = 0; } } void SelectPreviousFrame() { currentFrame--; if (currentFrame < 0) { currentFrame = currentSprites.Length - 1; } } Dictionary <string, bool> assetVisByName = new Dictionary <string, bool>(); bool FilterAsset(string filename) { var filter = filenameInput.Text; if (string.IsNullOrWhiteSpace(filter)) { return(true); } if (filename.IndexOf(filter, StringComparison.OrdinalIgnoreCase) >= 0) { return(true); } return(false); } void ApplyFilter(string filename) { assetVisByName.Clear(); assetList.Layout.AdjustChildren(); assetList.ScrollToTop(); // Select the first visible var firstVisible = assetVisByName.FirstOrDefault(kvp => kvp.Value); if (firstVisible.Key != null) { LoadAsset(firstVisible.Key); } } void AddAsset(ScrollPanelWidget list, string filepath, ScrollItemWidget template) { var filename = Path.GetFileName(filepath); var item = ScrollItemWidget.Setup(template, () => currentFilename == filename, () => { LoadAsset(filename); }); item.Get <LabelWidget>("TITLE").GetText = () => filepath; item.IsVisible = () => { bool visible; if (assetVisByName.TryGetValue(filepath, out visible)) { return(visible); } visible = FilterAsset(filepath); assetVisByName.Add(filepath, visible); return(visible); }; list.AddChild(item); } bool LoadAsset(string filename) { if (isVideoLoaded) { player.Stop(); player = null; isVideoLoaded = false; } if (string.IsNullOrEmpty(filename)) { return(false); } if (!modData.DefaultFileSystem.Exists(filename)) { return(false); } if (Path.GetExtension(filename.ToLowerInvariant()) == ".vqa") { player = panel.Get <VqaPlayerWidget>("PLAYER"); currentFilename = filename; player.Load(filename); player.DrawOverlay = false; isVideoLoaded = true; frameSlider.MaximumValue = (float)player.Video.Frames - 1; frameSlider.Ticks = 0; return(true); } else { currentFilename = filename; currentSprites = world.Map.Rules.Sequences.SpriteCache[filename]; currentFrame = 0; frameSlider.MaximumValue = (float)currentSprites.Length - 1; frameSlider.Ticks = currentSprites.Length; } return(true); } bool ShowSourceDropdown(DropDownButtonWidget dropdown) { Func <IReadOnlyPackage, ScrollItemWidget, ScrollItemWidget> setupItem = (source, itemTemplate) => { var item = ScrollItemWidget.Setup(itemTemplate, () => assetSource == source, () => { assetSource = source; PopulateAssetList(); }); item.Get <LabelWidget>("LABEL").GetText = () => source != null?Platform.UnresolvePath(source.Name) : "All Packages"; return(item); }; var sources = new[] { (IReadOnlyPackage)null }.Concat(acceptablePackages); dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 280, sources, setupItem); return(true); } void PopulateAssetList() { assetList.RemoveChildren(); availableShps.Clear(); var files = assetSource != null ? assetSource.Contents : modData.ModFiles.MountedPackages.SelectMany(f => f.Contents).Distinct(); foreach (var file in files.OrderBy(s => s)) { if (allowedExtensions.Any(ext => file.EndsWith(ext, true, CultureInfo.InvariantCulture))) { AddAsset(assetList, file, template); availableShps.Add(file); } } } bool ShowPaletteDropdown(DropDownButtonWidget dropdown, World world) { Func <string, ScrollItemWidget, ScrollItemWidget> setupItem = (name, itemTemplate) => { var item = ScrollItemWidget.Setup(itemTemplate, () => currentPalette == name, () => currentPalette = name); item.Get <LabelWidget>("LABEL").GetText = () => name; return(item); }; var palettes = world.WorldActor.TraitsImplementing <IProvidesAssetBrowserPalettes>() .SelectMany(p => p.PaletteNames); dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 280, palettes, setupItem); return(true); } }
public AssetBrowserLogic(Widget widget, Action onExit, World world) { this.world = world; panel = widget; assetSource = GlobalFileSystem.MountedFolders.First(); var ticker = panel.GetOrNull <LogicTickerWidget>("ANIMATION_TICKER"); if (ticker != null) { ticker.OnTick = () => { if (animateFrames) { SelectNextFrame(); } }; } var sourceDropdown = panel.GetOrNull <DropDownButtonWidget>("SOURCE_SELECTOR"); if (sourceDropdown != null) { sourceDropdown.OnMouseDown = _ => ShowSourceDropdown(sourceDropdown); sourceDropdown.GetText = () => { var name = assetSource != null?assetSource.Name.Replace(Platform.SupportDir, "^") : "All Packages"; if (name.Length > 15) { name = "..." + name.Substring(name.Length - 15); } return(name); }; } var spriteWidget = panel.GetOrNull <SpriteWidget>("SPRITE"); if (spriteWidget != null) { spriteWidget.GetSprite = () => currentSprites != null ? currentSprites[currentFrame] : null; currentPalette = spriteWidget.Palette; spriteWidget.GetPalette = () => currentPalette; } var paletteDropDown = panel.GetOrNull <DropDownButtonWidget>("PALETTE_SELECTOR"); if (paletteDropDown != null) { paletteDropDown.OnMouseDown = _ => ShowPaletteDropdown(paletteDropDown, world); paletteDropDown.GetText = () => currentPalette; } var colorPreview = panel.GetOrNull <ColorPreviewManagerWidget>("COLOR_MANAGER"); if (colorPreview != null) { colorPreview.Color = Game.Settings.Player.Color; } var colorDropdown = panel.GetOrNull <DropDownButtonWidget>("COLOR"); if (colorDropdown != null) { colorDropdown.IsDisabled = () => currentPalette != colorPreview.PaletteName; colorDropdown.OnMouseDown = _ => ShowColorDropDown(colorDropdown, colorPreview, world); panel.Get <ColorBlockWidget>("COLORBLOCK").GetColor = () => Game.Settings.Player.Color.RGB; } filenameInput = panel.Get <TextFieldWidget>("FILENAME_INPUT"); filenameInput.OnTextEdited = () => ApplyFilter(filenameInput.Text); var frameContainer = panel.GetOrNull("FRAME_SELECTOR"); if (frameContainer != null) { frameContainer.IsVisible = () => currentSprites != null && currentSprites.Length > 1; } frameSlider = panel.Get <SliderWidget>("FRAME_SLIDER"); frameSlider.OnChange += x => { currentFrame = (int)Math.Round(x); }; frameSlider.GetValue = () => currentFrame; var frameText = panel.GetOrNull <LabelWidget>("FRAME_COUNT"); if (frameText != null) { frameText.GetText = () => "{0} / {1}".F(currentFrame + 1, currentSprites.Length); } var playButton = panel.GetOrNull <ButtonWidget>("BUTTON_PLAY"); if (playButton != null) { playButton.OnClick = () => animateFrames = true; playButton.IsVisible = () => !animateFrames; } var pauseButton = panel.GetOrNull <ButtonWidget>("BUTTON_PAUSE"); if (pauseButton != null) { pauseButton.OnClick = () => animateFrames = false; pauseButton.IsVisible = () => animateFrames; } var stopButton = panel.GetOrNull <ButtonWidget>("BUTTON_STOP"); if (stopButton != null) { stopButton.OnClick = () => { frameSlider.Value = 0; currentFrame = 0; animateFrames = false; }; } var nextButton = panel.GetOrNull <ButtonWidget>("BUTTON_NEXT"); if (nextButton != null) { nextButton.OnClick = SelectNextFrame; } var prevButton = panel.GetOrNull <ButtonWidget>("BUTTON_PREV"); if (prevButton != null) { prevButton.OnClick = SelectPreviousFrame; } assetList = panel.Get <ScrollPanelWidget>("ASSET_LIST"); template = panel.Get <ScrollItemWidget>("ASSET_TEMPLATE"); PopulateAssetList(); var closeButton = panel.GetOrNull <ButtonWidget>("CLOSE_BUTTON"); if (closeButton != null) { closeButton.OnClick = () => { Ui.CloseWindow(); onExit(); } } ; } void SelectNextFrame() { currentFrame++; if (currentFrame >= currentSprites.Length) { currentFrame = 0; } } void SelectPreviousFrame() { currentFrame--; if (currentFrame < 0) { currentFrame = currentSprites.Length - 1; } } Dictionary <string, bool> assetVisByName = new Dictionary <string, bool>(); bool FilterAsset(string filename) { var filter = filenameInput.Text; if (string.IsNullOrWhiteSpace(filter)) { return(true); } if (filename.IndexOf(filter, StringComparison.OrdinalIgnoreCase) >= 0) { return(true); } return(false); } void ApplyFilter(string filename) { assetVisByName.Clear(); assetList.Layout.AdjustChildren(); assetList.ScrollToTop(); // Select the first visible var firstVisible = assetVisByName.FirstOrDefault(kvp => kvp.Value); if (firstVisible.Key != null) { LoadAsset(firstVisible.Key); } } void AddAsset(ScrollPanelWidget list, string filepath, ScrollItemWidget template) { var filename = Path.GetFileName(filepath); var item = ScrollItemWidget.Setup(template, () => currentFilename == filename, () => { LoadAsset(filename); }); item.Get <LabelWidget>("TITLE").GetText = () => filepath; item.IsVisible = () => { bool visible; if (assetVisByName.TryGetValue(filepath, out visible)) { return(visible); } visible = FilterAsset(filepath); assetVisByName.Add(filepath, visible); return(visible); }; list.AddChild(item); } bool LoadAsset(string filename) { if (string.IsNullOrEmpty(filename)) { return(false); } if (!GlobalFileSystem.Exists(filename)) { return(false); } currentFilename = filename; currentSprites = world.Map.SequenceProvider.SpriteLoader.LoadAllSprites(filename); currentFrame = 0; frameSlider.MaximumValue = (float)currentSprites.Length - 1; frameSlider.Ticks = currentSprites.Length; return(true); } bool ShowSourceDropdown(DropDownButtonWidget dropdown) { Func <IFolder, ScrollItemWidget, ScrollItemWidget> setupItem = (source, itemTemplate) => { var item = ScrollItemWidget.Setup(itemTemplate, () => assetSource == source, () => { assetSource = source; PopulateAssetList(); }); item.Get <LabelWidget>("LABEL").GetText = () => source != null?source.Name.Replace(Platform.SupportDir, "^") : "All Packages"; return(item); }; // TODO: Re-enable "All Packages" once list generation is done in a background thread // var sources = new[] { (IFolder)null }.Concat(GlobalFileSystem.MountedFolders); var sources = GlobalFileSystem.MountedFolders; dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 280, sources, setupItem); return(true); } void PopulateAssetList() { assetList.RemoveChildren(); availableShps.Clear(); // TODO: This is too slow to run in the main thread // var files = AssetSource != null ? AssetSource.AllFileNames() : // GlobalFileSystem.MountedFolders.SelectMany(f => f.AllFileNames()); if (assetSource == null) { return; } var files = assetSource.AllFileNames().OrderBy(s => s); foreach (var file in files) { if (AllowedExtensions.Any(ext => file.EndsWith(ext, true, CultureInfo.InvariantCulture))) { AddAsset(assetList, file, template); availableShps.Add(file); } } } bool ShowPaletteDropdown(DropDownButtonWidget dropdown, World world) { Func <PaletteFromFile, ScrollItemWidget, ScrollItemWidget> setupItem = (palette, itemTemplate) => { var name = palette.Name; var item = ScrollItemWidget.Setup(itemTemplate, () => currentPalette == name, () => currentPalette = name); item.Get <LabelWidget>("LABEL").GetText = () => name; return(item); }; var palettes = world.WorldActor.TraitsImplementing <PaletteFromFile>(); dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 280, palettes, setupItem); return(true); }
image_filters_application(PixelFormats format, ERenderOrigin RenderOrigin) : base(format, RenderOrigin) { m_step = new SliderWidget <T>(115, 5, 400, 11); m_radius = new SliderWidget <T>(115, 5 + 15, 400, 11 + 15); m_filters = new rbox_ctrl <T>(0.0, 0.0, 110.0, 210.0); m_normalize = new cbox_ctrl <T>(8.0, 215.0, "Normalize Filter"); m_refresh = new ButtonWidget <T>(8.0, 273.0, "Refresh", 8, 1, 1, 3); m_refresh.ButtonClick += RefreshImage; m_run = new ButtonWidget <T>(8.0, 253.0, "RUN Test!", 8, 1, 1, 3); m_run.ButtonClick += RunTest; m_single_step = new ButtonWidget <T>(8.0, 233.0, "Single Step", 8, 1, 1, 3); m_single_step.ButtonClick += SingleStep; m_cur_angle = (0.0); m_cur_filter = (1); m_num_steps = (0); m_num_pix = (0.0); m_time1 = (0); m_time2 = (0); m_ScanlinePacked = new ScanlinePacked8(); m_Rasterizer = new RasterizerScanlineAA <T>(); m_ScanlineUnpacked = new ScanlineUnpacked8(); m_SpanAllocator = new SpanAllocator(); AddChild(m_radius); AddChild(m_step); AddChild(m_filters); AddChild(m_run); AddChild(m_single_step); AddChild(m_normalize); AddChild(m_refresh); //m_single_step.text_size(7.5); m_normalize.SetFontSize(7.5); m_normalize.status(true); m_radius.label("Filter Radius={0:F2}"); m_step.label("Step={0:F2}"); m_radius.range(2.0, 8.0); m_radius.value(4.0); m_step.range(1.0, 10.0); m_step.value(5.0); m_filters.add_item("simple (NN)"); m_filters.add_item("bilinear"); m_filters.add_item("bicubic"); m_filters.add_item("spline16"); m_filters.add_item("spline36"); m_filters.add_item("hanning"); m_filters.add_item("hamming"); m_filters.add_item("hermite"); m_filters.add_item("kaiser"); m_filters.add_item("quadric"); m_filters.add_item("catrom"); m_filters.add_item("gaussian"); m_filters.add_item("bessel"); m_filters.add_item("mitchell"); m_filters.add_item("sinc"); m_filters.add_item("lanczos"); m_filters.add_item("blackman"); m_filters.cur_item(1); m_filters.border_width(0, 0); m_filters.background_color(new RGBA_Doubles(0.0, 0.0, 0.0, 0.1)); m_filters.text_size(6.0); m_filters.text_thickness(0.85); }
public blur_application(PixelFormats format, ERenderOrigin RenderOrigin) : base(format, RenderOrigin) { m_rbuf2 = new RasterBuffer(); m_shape_bounds = new RectDouble <T>(); m_method = new rbox_ctrl <T>(10.0, 10.0, 130.0, 70.0); m_radius = new SliderWidget <T>(130 + 10.0, 10.0 + 4.0, 130 + 300.0, 10.0 + 8.0 + 4.0); m_shadow_ctrl = new polygon_ctrl <T>(4); m_channel_r = new cbox_ctrl <T>(10.0, 80.0, "Red"); m_channel_g = new cbox_ctrl <T>(10.0, 95.0, "Green"); m_channel_b = new cbox_ctrl <T>(10.0, 110.0, "Blue"); m_FlattenCurves = new cbox_ctrl <T>(10, 315, "Convert And Flatten Curves"); m_FlattenCurves.status(true); AddChild(m_method); m_method.text_size(8); m_method.add_item("Stack Blur"); m_method.add_item("Recursive Blur"); m_method.add_item("Channels"); m_method.cur_item(1); AddChild(m_radius); m_radius.range(0.0, 40.0); m_radius.value(15.0); m_radius.label("Blur Radius={0:F2}"); AddChild(m_shadow_ctrl); AddChild(m_channel_r); AddChild(m_channel_g); AddChild(m_channel_b); AddChild(m_FlattenCurves); m_channel_g.status(true); m_sl = new ScanlinePacked8(); m_path = new PathStorage <T>(); m_shape = new ConvCurve <T>(m_path); m_path.RemoveAll(); m_path.MoveTo(28.47, 6.45); m_path.Curve3(21.58, 1.12, 19.82, 0.29); m_path.Curve3(17.19, -0.93, 14.21, -0.93); m_path.Curve3(9.57, -0.93, 6.57, 2.25); m_path.Curve3(3.56, 5.42, 3.56, 10.60); m_path.Curve3(3.56, 13.87, 5.03, 16.26); m_path.Curve3(7.03, 19.58, 11.99, 22.51); m_path.Curve3(16.94, 25.44, 28.47, 29.64); m_path.LineTo(28.47, 31.40); m_path.Curve3(28.47, 38.09, 26.34, 40.58); m_path.Curve3(24.22, 43.07, 20.17, 43.07); m_path.Curve3(17.09, 43.07, 15.28, 41.41); m_path.Curve3(13.43, 39.75, 13.43, 37.60); m_path.LineTo(13.53, 34.77); m_path.Curve3(13.53, 32.52, 12.38, 31.30); m_path.Curve3(11.23, 30.08, 9.38, 30.08); m_path.Curve3(7.57, 30.08, 6.42, 31.35); m_path.Curve3(5.27, 32.62, 5.27, 34.81); m_path.Curve3(5.27, 39.01, 9.57, 42.53); m_path.Curve3(13.87, 46.04, 21.63, 46.04); m_path.Curve3(27.59, 46.04, 31.40, 44.04); m_path.Curve3(34.28, 42.53, 35.64, 39.31); m_path.Curve3(36.52, 37.21, 36.52, 30.71); m_path.LineTo(36.52, 15.53); m_path.Curve3(36.52, 9.13, 36.77, 7.69); m_path.Curve3(37.01, 6.25, 37.57, 5.76); m_path.Curve3(38.13, 5.27, 38.87, 5.27); m_path.Curve3(39.65, 5.27, 40.23, 5.62); m_path.Curve3(41.26, 6.25, 44.19, 9.18); m_path.LineTo(44.19, 6.45); m_path.Curve3(38.72, -0.88, 33.74, -0.88); m_path.Curve3(31.35, -0.88, 29.93, 0.78); m_path.Curve3(28.52, 2.44, 28.47, 6.45); m_path.ClosePolygon(); m_path.MoveTo(28.47, 9.62); m_path.LineTo(28.47, 26.66); m_path.Curve3(21.09, 23.73, 18.95, 22.51); m_path.Curve3(15.09, 20.36, 13.43, 18.02); m_path.Curve3(11.77, 15.67, 11.77, 12.89); m_path.Curve3(11.77, 9.38, 13.87, 7.06); m_path.Curve3(15.97, 4.74, 18.70, 4.74); m_path.Curve3(22.41, 4.74, 28.47, 9.62); m_path.ClosePolygon(); IAffineTransformMatrix <T> shape_mtx = MatrixFactory <T> .NewIdentity(VectorDimension.Two); shape_mtx.Scale(M.New <T>(4.0)); shape_mtx.Translate(MatrixFactory <T> .CreateVector2D(150, 100)); m_path.Transform(shape_mtx); BoundingRect <T> .BoundingRectSingle(m_shape, 0, ref m_shape_bounds); m_shadow_ctrl.SetXN(0, m_shape_bounds.x1); m_shadow_ctrl.SetYN(0, m_shape_bounds.y1); m_shadow_ctrl.SetXN(1, m_shape_bounds.x2); m_shadow_ctrl.SetYN(1, m_shape_bounds.y1); m_shadow_ctrl.SetXN(2, m_shape_bounds.x2); m_shadow_ctrl.SetYN(2, m_shape_bounds.y2); m_shadow_ctrl.SetXN(3, m_shape_bounds.x1); m_shadow_ctrl.SetYN(3, m_shape_bounds.y2); m_shadow_ctrl.line_color(new RGBA_Doubles(0, 0.3, 0.5, 0.3)); }
public AssetBrowserLogic(Widget widget, Action onExit, World world) { panel = widget; var sourceDropdown = panel.Get <DropDownButtonWidget>("SOURCE_SELECTOR"); sourceDropdown.OnMouseDown = _ => ShowSourceDropdown(sourceDropdown); sourceDropdown.GetText = () => { var name = assetSource != null?assetSource.Name.Replace(Platform.SupportDir, "^") : "All Packages"; if (name.Length > 15) { name = "..." + name.Substring(name.Length - 15); } return(name); }; assetSource = FileSystem.MountedFolders.First(); spriteWidget = panel.Get <ShpImageWidget>("SPRITE"); currentPalette = world.WorldActor.TraitsImplementing <PaletteFromFile>().First(p => p.Name == spriteWidget.Palette); var paletteDropDown = panel.Get <DropDownButtonWidget>("PALETTE_SELECTOR"); paletteDropDown.OnMouseDown = _ => ShowPaletteDropdown(paletteDropDown, world); paletteDropDown.GetText = () => currentPalette.Name; var colorPreview = panel.Get <ColorPreviewManagerWidget>("COLOR_MANAGER"); colorPreview.Color = Game.Settings.Player.Color; var color = panel.Get <DropDownButtonWidget>("COLOR"); color.IsDisabled = () => currentPalette.Name != colorPreview.Palette; color.OnMouseDown = _ => ShowColorDropDown(color, colorPreview, world); var block = panel.Get <ColorBlockWidget>("COLORBLOCK"); block.GetColor = () => Game.Settings.Player.Color.RGB; filenameInput = panel.Get <TextFieldWidget>("FILENAME_INPUT"); filenameInput.OnEnterKey = () => LoadAsset(filenameInput.Text); frameSlider = panel.Get <SliderWidget>("FRAME_SLIDER"); frameSlider.MaximumValue = (float)spriteWidget.FrameCount; frameSlider.Ticks = spriteWidget.FrameCount + 1; frameSlider.IsVisible = () => spriteWidget.FrameCount > 0; frameSlider.OnChange += x => { spriteWidget.Frame = (int)Math.Round(x); }; frameSlider.GetValue = () => spriteWidget.Frame; panel.Get <LabelWidget>("FRAME_COUNT").GetText = () => "{0} / {1}".F(spriteWidget.Frame + 1, spriteWidget.FrameCount + 1); playButton = panel.Get <ButtonWidget>("BUTTON_PLAY"); playButton.OnClick = () => { spriteWidget.LoopAnimation = true; playButton.Visible = false; pauseButton.Visible = true; }; pauseButton = panel.Get <ButtonWidget>("BUTTON_PAUSE"); pauseButton.OnClick = () => { spriteWidget.LoopAnimation = false; playButton.Visible = true; pauseButton.Visible = false; }; panel.Get <ButtonWidget>("BUTTON_STOP").OnClick = () => { spriteWidget.LoopAnimation = false; frameSlider.Value = 0; spriteWidget.Frame = 0; playButton.Visible = true; pauseButton.Visible = false; }; panel.Get <ButtonWidget>("BUTTON_NEXT").OnClick = () => { spriteWidget.RenderNextFrame(); }; panel.Get <ButtonWidget>("BUTTON_PREV").OnClick = () => { spriteWidget.RenderPreviousFrame(); }; panel.Get <ButtonWidget>("LOAD_BUTTON").OnClick = () => { LoadAsset(filenameInput.Text); }; assetList = panel.Get <ScrollPanelWidget>("ASSET_LIST"); template = panel.Get <ScrollItemWidget>("ASSET_TEMPLATE"); PopulateAssetList(); panel.Get <ButtonWidget>("CLOSE_BUTTON").OnClick = () => { Ui.CloseWindow(); onExit(); }; }
public AssetBrowserLogic(Widget widget, Action onExit, ModData modData, WorldRenderer worldRenderer) { world = worldRenderer.World; this.modData = modData; panel = widget; var colorPickerPalettes = world.WorldActor.TraitsImplementing <IProvidesAssetBrowserColorPickerPalettes>() .SelectMany(p => p.ColorPickerPaletteNames) .ToArray(); palettes = world.WorldActor.TraitsImplementing <IProvidesAssetBrowserPalettes>() .SelectMany(p => p.PaletteNames) .Concat(colorPickerPalettes) .ToArray(); var ticker = panel.GetOrNull <LogicTickerWidget>("ANIMATION_TICKER"); if (ticker != null) { ticker.OnTick = () => { if (animateFrames && currentSprites != null) { SelectNextFrame(); } }; } var sourceDropdown = panel.GetOrNull <DropDownButtonWidget>("SOURCE_SELECTOR"); if (sourceDropdown != null) { sourceDropdown.OnMouseDown = _ => ShowSourceDropdown(sourceDropdown); var sourceName = new CachedTransform <IReadOnlyPackage, string>(GetSourceDisplayName); sourceDropdown.GetText = () => sourceName.Update(assetSource); } var spriteWidget = panel.GetOrNull <SpriteWidget>("SPRITE"); if (spriteWidget != null) { spriteWidget.GetSprite = () => currentSprites != null ? currentSprites[currentFrame] : null; currentPalette = spriteWidget.Palette; spriteScale = spriteWidget.Scale; spriteWidget.GetPalette = () => currentPalette; spriteWidget.IsVisible = () => !isVideoLoaded && !isLoadError && currentSprites != null; spriteWidget.GetScale = () => spriteScale; } var playerWidget = panel.GetOrNull <VideoPlayerWidget>("PLAYER"); if (playerWidget != null) { playerWidget.IsVisible = () => isVideoLoaded && !isLoadError; } var modelWidget = panel.GetOrNull <ModelWidget>("VOXEL"); if (modelWidget != null) { modelWidget.GetVoxel = () => currentVoxel; currentPalette = modelWidget.Palette; modelScale = modelWidget.Scale; modelWidget.GetPalette = () => currentPalette; modelWidget.GetPlayerPalette = () => currentPalette; modelWidget.GetRotation = () => modelOrientation; modelWidget.IsVisible = () => !isVideoLoaded && !isLoadError && currentVoxel != null; modelWidget.GetScale = () => modelScale; } var errorLabelWidget = panel.GetOrNull("ERROR"); if (errorLabelWidget != null) { errorLabelWidget.IsVisible = () => isLoadError; } var paletteDropDown = panel.GetOrNull <DropDownButtonWidget>("PALETTE_SELECTOR"); if (paletteDropDown != null) { paletteDropDown.OnMouseDown = _ => ShowPaletteDropdown(paletteDropDown); paletteDropDown.GetText = () => currentPalette; paletteDropDown.IsVisible = () => currentSprites != null || currentVoxel != null; panel.GetOrNull <LabelWidget>("PALETTE_DESC").IsVisible = () => currentSprites != null || currentVoxel != null; } var colorManager = modData.DefaultRules.Actors[SystemActors.World].TraitInfo <ColorPickerManagerInfo>(); colorManager.Color = Game.Settings.Player.Color; var colorDropdown = panel.GetOrNull <DropDownButtonWidget>("COLOR"); if (colorDropdown != null) { colorDropdown.IsDisabled = () => !colorPickerPalettes.Contains(currentPalette); colorDropdown.OnMouseDown = _ => ColorPickerLogic.ShowColorDropDown(colorDropdown, colorManager, worldRenderer); colorDropdown.IsVisible = () => currentSprites != null || currentVoxel != null; panel.Get <ColorBlockWidget>("COLORBLOCK").GetColor = () => colorManager.Color; } filenameInput = panel.Get <TextFieldWidget>("FILENAME_INPUT"); filenameInput.OnTextEdited = () => ApplyFilter(); filenameInput.OnEscKey = _ => { if (string.IsNullOrEmpty(filenameInput.Text)) { filenameInput.YieldKeyboardFocus(); } else { filenameInput.Text = ""; filenameInput.OnTextEdited(); } return(true); }; var frameContainer = panel.GetOrNull("FRAME_SELECTOR"); if (frameContainer != null) { frameContainer.IsVisible = () => (currentSprites != null && currentSprites.Length > 1) || (isVideoLoaded && player != null && player.Video != null && player.Video.FrameCount > 1) || currentSoundFormat != null; } frameSlider = panel.GetOrNull <SliderWidget>("FRAME_SLIDER"); if (frameSlider != null) { frameSlider.OnChange += x => { if (!isVideoLoaded) { currentFrame = (int)Math.Round(x); } }; frameSlider.GetValue = () => { if (isVideoLoaded) { return(player.Video.CurrentFrameIndex); } if (currentSound != null) { return(currentSound.SeekPosition * currentSoundFormat.SampleRate); } return(currentFrame); }; frameSlider.IsDisabled = () => isVideoLoaded || currentSoundFormat != null; } var frameText = panel.GetOrNull <LabelWidget>("FRAME_COUNT"); if (frameText != null) { frameText.GetText = () => { if (isVideoLoaded) { return($"{player.Video.CurrentFrameIndex + 1} / {player.Video.FrameCount}"); } if (currentSoundFormat != null) { return($"{Math.Round(currentSoundFormat.LengthInSeconds, 3)} sec"); } return($"{currentFrame} / {currentSprites.Length - 1}"); }; } var playButton = panel.GetOrNull <ButtonWidget>("BUTTON_PLAY"); if (playButton != null) { playButton.OnClick = () => { if (isVideoLoaded) { player.Play(); } else if (currentSoundFormat != null) { if (currentSound != null) { Game.Sound.StopSound(currentSound); } currentSound = Game.Sound.Play(currentSoundFormat, Game.Sound.SoundVolume); } else { animateFrames = true; } }; playButton.IsVisible = () => isVideoLoaded ? player.Paused : !animateFrames || currentSoundFormat != null; } var pauseButton = panel.GetOrNull <ButtonWidget>("BUTTON_PAUSE"); if (pauseButton != null) { pauseButton.OnClick = () => { if (isVideoLoaded) { player.Pause(); } else { animateFrames = false; } }; pauseButton.IsVisible = () => isVideoLoaded ? !player.Paused : (animateFrames && currentSoundFormat == null); } var stopButton = panel.GetOrNull <ButtonWidget>("BUTTON_STOP"); if (stopButton != null) { stopButton.OnClick = () => { if (isVideoLoaded) { player.Stop(); } else if (currentSound != null) { Game.Sound.StopSound(currentSound); } else { currentFrame = 0; animateFrames = false; } if (frameSlider != null) { frameSlider.Value = 0; } }; } var nextButton = panel.GetOrNull <ButtonWidget>("BUTTON_NEXT"); if (nextButton != null) { nextButton.OnClick = () => { if (!isVideoLoaded) { nextButton.OnClick = SelectNextFrame; } }; nextButton.IsVisible = () => !isVideoLoaded && currentSoundFormat == null; } var prevButton = panel.GetOrNull <ButtonWidget>("BUTTON_PREV"); if (prevButton != null) { prevButton.OnClick = () => { if (!isVideoLoaded) { SelectPreviousFrame(); } }; prevButton.IsVisible = () => !isVideoLoaded && currentSoundFormat == null; } var spriteScaleSlider = panel.GetOrNull <SliderWidget>("SPRITE_SCALE_SLIDER"); if (spriteScaleSlider != null) { spriteScaleSlider.OnChange += x => spriteScale = x; spriteScaleSlider.GetValue = () => spriteScale; spriteScaleSlider.IsVisible = () => currentSprites != null; panel.GetOrNull <LabelWidget>("SPRITE_SCALE").IsVisible = () => currentSprites != null; } var voxelContainer = panel.GetOrNull("VOXEL_SELECTOR"); if (voxelContainer != null) { voxelContainer.IsVisible = () => currentVoxel != null; } var rollSlider = panel.GetOrNull <SliderWidget>("ROLL_SLIDER"); if (rollSlider != null) { rollSlider.OnChange += x => { var roll = (int)x; modelOrientation = modelOrientation.WithRoll(new WAngle(roll)); }; rollSlider.GetValue = () => modelOrientation.Roll.Angle; } var pitchSlider = panel.GetOrNull <SliderWidget>("PITCH_SLIDER"); if (pitchSlider != null) { pitchSlider.OnChange += x => { var pitch = (int)x; modelOrientation = modelOrientation.WithPitch(new WAngle(pitch)); }; pitchSlider.GetValue = () => modelOrientation.Pitch.Angle; } var yawSlider = panel.GetOrNull <SliderWidget>("YAW_SLIDER"); if (yawSlider != null) { yawSlider.OnChange += x => { var yaw = (int)x; modelOrientation = modelOrientation.WithYaw(new WAngle(yaw)); }; yawSlider.GetValue = () => modelOrientation.Yaw.Angle; } var modelScaleSlider = panel.GetOrNull <SliderWidget>("MODEL_SCALE_SLIDER"); if (modelScaleSlider != null) { modelScaleSlider.OnChange += x => modelScale = x; modelScaleSlider.GetValue = () => modelScale; modelScaleSlider.IsVisible = () => currentVoxel != null; panel.GetOrNull <LabelWidget>("MODEL_SCALE").IsVisible = () => currentVoxel != null; } var assetBrowserModData = modData.Manifest.Get <AssetBrowser>(); allowedSpriteExtensions = assetBrowserModData.SpriteExtensions; allowedModelExtensions = assetBrowserModData.ModelExtensions; allowedAudioExtensions = assetBrowserModData.AudioExtensions; allowedVideoExtensions = assetBrowserModData.VideoExtensions; allowedExtensions = allowedSpriteExtensions .Union(allowedModelExtensions) .Union(allowedAudioExtensions) .Union(allowedVideoExtensions) .ToArray(); acceptablePackages = modData.ModFiles.MountedPackages.Where(p => p.Contents.Any(c => allowedExtensions.Contains(Path.GetExtension(c).ToLowerInvariant()))); assetList = panel.Get <ScrollPanelWidget>("ASSET_LIST"); template = panel.Get <ScrollItemWidget>("ASSET_TEMPLATE"); PopulateAssetList(); var closeButton = panel.GetOrNull <ButtonWidget>("CLOSE_BUTTON"); if (closeButton != null) { closeButton.OnClick = () => { ClearLoadedAssets(); Ui.CloseWindow(); onExit(); } } ; } void SelectNextFrame() { currentFrame++; if (currentFrame >= currentSprites.Length) { currentFrame = 0; } } void SelectPreviousFrame() { currentFrame--; if (currentFrame < 0) { currentFrame = currentSprites.Length - 1; } }
public virtual TResult Visit(SliderWidget expression, TEnvironment environment) { expression.Values.ForEach(x => x.Accept(this, environment)); return(default(TResult)); }
public Img(ComponentPlayer player, string path, TerrainRaycastResult?Point1, SubsystemTerrain subsystemTerrain) { path_img = path; Point = new Point3(Point1.Value.CellFace.Point.X, Point1.Value.CellFace.Point.Y, Point1.Value.CellFace.Point.Z); m_subsystemTerrain = subsystemTerrain; this.player = player; WidgetsManager.LoadWidgetContents(this, this, ContentManager.Get <XElement>("WE/DialogsWE/ImgDialog")); // WidgetsManager.LoadWidgetContents(this, this, XElement.Load(@"D:\Games\WSC\Content\WE\DialogsWE\ImgDialog.xml")); m_okButton = this.Children.Find <ButtonWidget>("Img_Dialog.OK", true); m_cancelButton = this.Children.Find <ButtonWidget>("Img_Dialog.Cancel", true); m_type_creatingButton = this.Children.Find <ButtonWidget>("Img_Dialog.type_cr_btn", true); m_type_creatingLabel = this.Children.Find <LabelWidget>("Img_Dialog.type_cr_text", true); m_resizeSlider = this.Children.Find <SliderWidget>("Img_Dialog.resize_sl", true); m_furniture_resolutionSlider = this.Children.Find <SliderWidget>("Img_Dialog.furn_res_sl", true); m_deep_colorSlider = this.Children.Find <SliderWidget>("Img_Dialog.Slider_deep", true); m_color_ofsetSlider = this.Children.Find <SliderWidget>("Img_Dialog.ofst_sl", true); m_posButton = this.Children.Find <ButtonWidget>("Img_Dialog.pos_sel", true); m_rotButton = this.Children.Find <ButtonWidget>("Img_Dialog.rot_sel", true); m_posLabel = this.Children.Find <LabelWidget>("Img_Dialog.pos_txt", true); m_rotLabel = this.Children.Find <LabelWidget>("Img_Dialog.rot_txt", true); m_colors_useBox = this.Children.Find <CheckboxWidget>("Img_Dialog.Line0", true); m_color_saveBox = this.Children.Find <CheckboxWidget>("Img_Dialog.Line1", true); m_mirrorBox = this.Children.Find <CheckboxWidget>("Img_Dialog.mirror", true); m_resizeSlider.MinValue = 1f; m_resizeSlider.MaxValue = 8f; m_furniture_resolutionSlider.MinValue = 2f; m_furniture_resolutionSlider.MaxValue = 16f; m_color_ofsetSlider.MinValue = 0f; m_color_ofsetSlider.MaxValue = 8f; m_deep_colorSlider.MinValue = 2f; m_deep_colorSlider.MaxValue = 16f; t_c_txt = "Furniture"; m_colors_useBox.IsChecked = false; m_color_saveBox.IsChecked = false; m_resizeSlider.Value = 2; m_furniture_resolutionSlider.Value = 16; m_deep_colorSlider.Value = 16; pos_txt = "Horizontally"; rot_txt = "Front"; }
public AssetBrowserLogic(Widget widget, Action onExit, World world) { panel = widget; var sourceDropdown = panel.Get <DropDownButtonWidget>("SOURCE_SELECTOR"); sourceDropdown.OnMouseDown = _ => ShowSourceDropdown(sourceDropdown); sourceDropdown.GetText = () => { var name = AssetSource != null ? AssetSource.Name : "All Packages"; if (name.Length > 15) { name = "..." + name.Substring(name.Length - 15); } return(name); }; AssetSource = FileSystem.MountedFolders.First(); spriteImage = panel.Get <ShpImageWidget>("SPRITE"); filenameInput = panel.Get <TextFieldWidget>("FILENAME_INPUT"); filenameInput.Text = spriteImage.Image + ".shp"; filenameInput.OnEnterKey = () => LoadAsset(filenameInput.Text); frameSlider = panel.Get <SliderWidget>("FRAME_SLIDER"); frameSlider.MaximumValue = (float)spriteImage.FrameCount; frameSlider.Ticks = spriteImage.FrameCount + 1; frameSlider.OnChange += x => { spriteImage.Frame = (int)Math.Round(x); }; frameSlider.GetValue = () => spriteImage.Frame; panel.Get <LabelWidget>("FRAME_COUNT").GetText = () => "{0}/{1}".F(spriteImage.Frame, spriteImage.FrameCount); playButton = panel.Get <ButtonWidget>("BUTTON_PLAY"); playButton.OnClick = () => { spriteImage.LoopAnimation = true; playButton.Visible = false; pauseButton.Visible = true; }; pauseButton = panel.Get <ButtonWidget>("BUTTON_PAUSE"); pauseButton.OnClick = () => { spriteImage.LoopAnimation = false; playButton.Visible = true; pauseButton.Visible = false; }; panel.Get <ButtonWidget>("BUTTON_STOP").OnClick = () => { spriteImage.LoopAnimation = false; frameSlider.Value = 0; spriteImage.Frame = 0; playButton.Visible = true; pauseButton.Visible = false; }; panel.Get <ButtonWidget>("BUTTON_NEXT").OnClick = () => { spriteImage.RenderNextFrame(); }; panel.Get <ButtonWidget>("BUTTON_PREV").OnClick = () => { spriteImage.RenderPreviousFrame(); }; panel.Get <ButtonWidget>("LOAD_BUTTON").OnClick = () => { LoadAsset(filenameInput.Text); }; assetList = panel.Get <ScrollPanelWidget>("ASSET_LIST"); template = panel.Get <ScrollItemWidget>("ASSET_TEMPLATE"); PopulateAssetList(); var palette = (WidgetUtils.ActiveModId() == "d2k") ? "d2k.pal" : "egopal.pal"; panel.Get <ButtonWidget>("EXPORT_BUTTON").OnClick = () => { var ExtractGameFiles = new string[][] { new string[] { "--extract", WidgetUtils.ActiveModId(), palette, "--userdir" }, new string[] { "--extract", WidgetUtils.ActiveModId(), "{0}.shp".F(spriteImage.Image), "--userdir" }, }; var ExportToPng = new string[][] { new string[] { "--png", Platform.SupportDir + "{0}.shp".F(spriteImage.Image), Platform.SupportDir + palette }, }; var ImportFromPng = new string[][] { }; var args = new WidgetArgs() { { "ExtractGameFiles", ExtractGameFiles }, { "ExportToPng", ExportToPng }, { "ImportFromPng", ImportFromPng } }; Ui.OpenWindow("CONVERT_ASSETS_PANEL", args); }; panel.Get <ButtonWidget>("EXTRACT_BUTTON").OnClick = () => { var ExtractGameFilesList = new List <string[]>(); var ExportToPngList = new List <string[]>(); ExtractGameFilesList.Add(new string[] { "--extract", WidgetUtils.ActiveModId(), palette, "--userdir" }); foreach (var shp in AvailableShps) { ExtractGameFilesList.Add(new string[] { "--extract", WidgetUtils.ActiveModId(), shp, "--userdir" }); ExportToPngList.Add(new string[] { "--png", Platform.SupportDir + shp, Platform.SupportDir + palette }); Console.WriteLine(Platform.SupportDir + shp); } var ExtractGameFiles = ExtractGameFilesList.ToArray(); var ExportToPng = ExportToPngList.ToArray(); var ImportFromPng = new string[][] { }; var args = new WidgetArgs() { { "ExtractGameFiles", ExtractGameFiles }, { "ExportToPng", ExportToPng }, { "ImportFromPng", ImportFromPng } }; Ui.OpenWindow("CONVERT_ASSETS_PANEL", args); }; panel.Get <ButtonWidget>("IMPORT_BUTTON").OnClick = () => { var imageSizeInput = panel.Get <TextFieldWidget>("IMAGE_SIZE_INPUT"); var imageFilename = panel.Get <TextFieldWidget>("IMAGE_FILENAME_INPUT"); var ExtractGameFiles = new string[][] { }; var ExportToPng = new string[][] { }; var ImportFromPng = new string[][] { new string[] { "--shp", Platform.SupportDir + imageFilename.Text, imageSizeInput.Text }, }; var args = new WidgetArgs() { { "ExtractGameFiles", ExtractGameFiles }, { "ExportToPng", ExportToPng }, { "ImportFromPng", ImportFromPng } }; Ui.OpenWindow("CONVERT_ASSETS_PANEL", args); }; panel.Get <ButtonWidget>("CLOSE_BUTTON").OnClick = () => { Ui.CloseWindow(); onExit(); }; }