11/* eslint-disable prefer-const */
2- import { IPlayerUISession , Widget , WidgetComponentClipboard , WidgetGroupSelectionMode } from "@minecraft/server-editor" ;
2+ import { IPlayerUISession , ProgressIndicatorPropertyItemVariant , Widget , WidgetComponentClipboard , WidgetGroupSelectionMode } from "@minecraft/server-editor" ;
33import { UIPane } from "editor/pane/builder" ;
44import { EditorModule } from "./base" ;
55import { Pattern } from "@modules/pattern" ;
6- import { regionSize , Server , Vector } from "@notbeer-api" ;
6+ import { regionSize , Server , Thread , Vector } from "@notbeer-api" ;
77import { PatternUIBuilder } from "editor/pane/pattern" ;
88import { MaskUIBuilder } from "editor/pane/mask" ;
99import { Mask } from "@modules/mask" ;
1010import { Cardinal } from "@modules/directions" ;
1111import { getSession } from "server/sessions" ;
1212import { system } from "@minecraft/server" ;
13+ import { Jobs } from "@modules/jobs" ;
1314
1415enum RegionOperatorMode {
1516 Fill ,
@@ -31,6 +32,7 @@ export class RegionOpModule extends EditorModule {
3132 private widgetComponents : WidgetComponentClipboard [ ] = [ ] ;
3233
3334 private tickId : number ;
35+ private thread ?: Thread ;
3436
3537 private enableMask = false ;
3638 private enableHeightMask = false ;
@@ -46,7 +48,7 @@ export class RegionOpModule extends EditorModule {
4648
4749 constructor ( session : IPlayerUISession ) {
4850 super ( session ) ;
49- const tool = session . toolRail . addTool ( "worldedit:region_operations" , { title : "WorldEdit Region Operations" } ) ;
51+ const tool = session . toolRail . addTool ( "worldedit:region_operations" , { title : "WorldEdit Region Operations" , icon : "pack://textures/editor/region_operations_tool.png" } ) ;
5052 const widgetGroup = session . extensionContext . widgetManager . createGroup ( { groupSelectionMode : WidgetGroupSelectionMode . None , visible : true } ) ;
5153
5254 this . widget = widgetGroup . createWidget ( Vector . ZERO , { visible : true } ) ;
@@ -77,6 +79,7 @@ export class RegionOpModule extends EditorModule {
7779 enable : this . canOperate ( ) ,
7880 pressed : this . performOperation . bind ( this ) ,
7981 } ,
82+ { type : "progress" , uniqueId : "operationProgress" , variant : ProgressIndicatorPropertyItemVariant . ProgressBar , visible : false } ,
8083 { type : "divider" } ,
8184 {
8285 type : "dropdown" ,
@@ -188,6 +191,15 @@ export class RegionOpModule extends EditorModule {
188191 lastCardinal = cardinal ;
189192 this . updateWidgets ( ) ;
190193 }
194+
195+ if ( this . thread && ! this . thread . isActive ) this . thread = undefined ;
196+ const job = this . thread ? Jobs . getJobsForThread ( this . thread ) [ 0 ] : undefined ;
197+ if ( job ) {
198+ this . pane . setVisibility ( "operationProgress" , true ) ;
199+ this . pane . setValue ( "operationProgress" , Jobs . getProgress ( job ) ) ;
200+ } else {
201+ this . pane . setVisibility ( "operationProgress" , false ) ;
202+ }
191203 } , 2 ) ;
192204 }
193205
@@ -206,7 +218,7 @@ export class RegionOpModule extends EditorModule {
206218 [ RegionOperatorMode . Outline ] : "faces" ,
207219 [ RegionOperatorMode . Wall ] : "walls" ,
208220 } [ this . mode ] ;
209- Server . command . getRegistration ( command ) . callback ( this . player , "editor-callback" , args ) ;
221+ this . thread = Server . command . getRegistration ( command ) . callback ( this . player , "editor-callback" , args ) ;
210222 } else if ( this . mode === RegionOperatorMode . Stack ) {
211223 Server . command . getRegistration ( "stack" ) . callback (
212224 this . player ,
@@ -220,7 +232,7 @@ export class RegionOpModule extends EditorModule {
220232 )
221233 ) ;
222234 } else if ( this . mode === RegionOperatorMode . Move ) {
223- Server . command . getRegistration ( "move" ) . callback (
235+ this . thread = Server . command . getRegistration ( "move" ) . callback (
224236 this . player ,
225237 "editor-callback" ,
226238 new Map (
@@ -232,7 +244,7 @@ export class RegionOpModule extends EditorModule {
232244 )
233245 ) ;
234246 } else if ( this . mode === RegionOperatorMode . Smooth ) {
235- Server . command . getRegistration ( "smooth" ) . callback (
247+ this . thread = Server . command . getRegistration ( "smooth" ) . callback (
236248 this . player ,
237249 "editor-callback" ,
238250 new Map (
0 commit comments