Skip to main content

CommandContext

Struct CommandContext 

Source
pub struct CommandContext {
Show 38 fields pub int_vec_pool: IntVecPool, pub project_dir: PathBuf, pub emote_key: Option<u32>, pub images: ImageManager, pub layers: LayerManager, pub solid_white: ImageHandle, pub bgm: BgmEngine, pub audio: AudioHub, pub koe: KoeEngine, pub pcm: PcmEngine, pub se: SeEngine, pub movie: MovieManager, pub ids: RuntimeConstants, pub gfx: GfxRuntime, pub ui: UiRuntime, pub font_cache: FontCache, pub input: InputState, pub script_input: InputState, pub screen_w: u32, pub screen_h: u32, pub wait: VmWait, pub net: TnmNet, pub tables: AssetTables, pub stack: Vec<Value>, pub unknown: UnknownOpRecorder, pub globals: GlobalState, pub tonecurve: ToneCurveRuntime, pub excall_state: ExcallCompatState, pub external_forms: Option<Arc<dyn ExternalFormHandler>>, pub native_ui_backend: Option<Arc<dyn NativeUiBackend>>, pub native_ui: NativeUiRuntime, pub current_scene_no: Option<i64>, pub current_scene_name: Option<String>, pub current_line_no: i64, pub vm_call: Option<VmCallMeta>, pub pending_scene_restart: Option<(String, i32)>, pub local_save_snapshot: Option<LocalSaveSnapshot>, pub pending_auto_savepoint: bool, /* private fields */
}

Fields§

§int_vec_pool: IntVecPool

Reused element/chain buffers (see IntVecPool).

§project_dir: PathBuf§emote_key: Option<u32>

Project-wide variable DWORD used by encrypted Emote PSB files. Native hosts preload/recover this before scene execution; direct VM users still pick up an explicitly configured key.toml value here.

§images: ImageManager§layers: LayerManager§solid_white: ImageHandle

1x1 white sprite used for screen-space overlays (filters, etc.).

§bgm: BgmEngine§audio: AudioHub§koe: KoeEngine§pcm: PcmEngine§se: SeEngine§movie: MovieManager§ids: RuntimeConstants

Runtime numeric constants (form/element/op codes).

§gfx: GfxRuntime

Graphics runtime state for stage/object sprite binding.

§ui: UiRuntime

UI runtime (text window, message waits, etc.).

§font_cache: FontCache

Shared font cache for stage/object text rendering.

§input: InputState

Runtime-visible input state (button manager, waits, runtime systems).

§script_input: InputState

Script-visible input state (Gp_script_input in the original engine).

§screen_w: u32

Current render target size (used for UI layout).

§screen_h: u32§wait: VmWait

VM blocking state (WAIT / WAIT_KEY).

§net: TnmNet

Lightweight network/browser helper mirroring the engine’s tnm_net slot.

§tables: AssetTables

Gameexe-driven asset tables (CGTABLE / DATABASE / THUMBTABLE).

§stack: Vec<Value>

Value stack used by form handlers to return results.

§unknown: UnknownOpRecorder§globals: GlobalState§tonecurve: ToneCurveRuntime§excall_state: ExcallCompatState§external_forms: Option<Arc<dyn ExternalFormHandler>>

Optional project-provided form handler (game-specific).

§native_ui_backend: Option<Arc<dyn NativeUiBackend>>

Optional platform-native UI backend used by mobile ports.

§native_ui: NativeUiRuntime§current_scene_no: Option<i64>

Current scene number tracked by the VM.

§current_scene_name: Option<String>

Current scene name tracked by the VM.

§current_line_no: i64

Current source line tracked by the VM (CD_NL).

§vm_call: Option<VmCallMeta>

Current VM-originated form call metadata. Form handlers read this instead of relying on trailing wrapper arguments.

§pending_scene_restart: Option<(String, i32)>

Explicit scene and Z label supplied by GLOBAL.RETURNMENU(scene[, z]). Original cmd_global.cpp routes these overloads through tnm_syscom_restart_from_scene(), not the return-to-menu proc.

§local_save_snapshot: Option<LocalSaveSnapshot>

Engine-equivalent of Gp_eng->m_local_save. Built at GLOBAL_SAVEPOINT and refreshed by tnm_load_local_on_file-equivalent load. Save-to-file dispatch reads from here so the saved stream reflects the savepoint, not the live menu/UI state when the user picks a slot.

§pending_auto_savepoint: bool

Set when the engine wants the next safe boundary (post-command, pre-next-step) to (re)build local_save_snapshot. Mirrors C++ tnm_msg_proc_start_msg_block calling tnm_init_local_save + tnm_set_save_point at message-block start. Form handlers can’t build the snapshot themselves (they don’t see SceneVm), so they request via this flag and the VM drains it at a safe point.

Implementations§

Source§

impl CommandContext

Source

pub fn sync_script_input_from_runtime(&mut self)

Source

pub fn proc_generation(&self) -> u64

Source

pub fn request_read_flag_no(&mut self)

Source

pub fn request_read_flag_no_for_mwnd( &mut self, form_id: u32, stage_idx: i64, mwnd_idx: usize, )

Source

pub fn request_read_flag_no_for_selbtn(&mut self)

Source

pub fn take_read_flag_no_request(&mut self) -> bool

Source

pub fn discard_read_flag_no_request(&mut self)

Drop the target retained by take_read_flag_no_request() when the current scene uses the legacy command ABI with no trailing read-flag operand. Do not submit -1: old scenes did not perform the newer read/skip bookkeeping for that command at all.

Source

pub fn submit_read_flag_no(&mut self, value: i32)

Source

pub fn request_runtime_save(&mut self, kind: RuntimeSaveKind, index: usize)

Source

pub fn request_auto_savepoint(&mut self)

Form-handler entrypoint matching C++ tnm_msg_proc_start_msg_block’s tnm_init_local_save + (gated) tnm_set_save_point calls. Honors the dont_set_save_point script flag (suspends auto SAVEPOINT for special blocks). The VM drains the request at the next safe boundary and runs build_local_save_snapshot.

Source

pub fn take_pending_auto_savepoint(&mut self) -> bool

Source

pub fn request_sel_point_with_result(&mut self, result: i64)

Source

pub fn take_pending_sel_point_result(&mut self) -> Option<i32>

Source

pub fn request_runtime_load(&mut self, kind: RuntimeSaveKind, index: usize)

Source

pub fn take_runtime_save_request(&mut self) -> Option<RuntimeSaveRequest>

Source

pub fn take_runtime_load_request(&mut self) -> Option<RuntimeLoadRequest>

Source

pub fn begin_runtime_load_apply(&mut self)

Source

pub fn mark_runtime_load_completed(&mut self)

Source

pub fn take_runtime_load_completed(&mut self) -> bool

Source

pub fn needs_continuous_frame(&self) -> bool

Source

pub fn last_proc_kind(&self) -> ProcKind

Source

pub fn request_proc_boundary(&mut self, kind: ProcKind)

Source

pub fn request_disp_proc_boundary(&mut self)

Source

pub fn request_message_block_proc_boundary(&mut self)

Source

pub fn request_message_wait_proc_boundary(&mut self)

Source

pub fn request_wait_proc_boundary(&mut self, kind: ProcKind)

Source

pub fn finish_wipe_runtime(&mut self)

End the active wipe with the same teardown performed by C_tnm_wipe::end() in the original engine.

GlobalState::finish_wipe() only clears the timing marker and is kept for whole-runtime resets. Live wipe completion must use this method so the copied NEXT stage and all of its backend sprites are reinitialized.

Source

pub fn notify_wait_key(&mut self) -> bool

Source

pub fn notify_movie_wait_down_up(&mut self, result: i64) -> bool

Source

pub fn new(project_dir: PathBuf) -> Self

Source

pub fn set_active_append(&mut self, append_dir: String, append_name: String)

Update the active append selected by the original Gp_dir state and keep all resource managers that cache it in sync. SceneVm observes the same value and reloads Scene.pck only when this directory changes.

Source

pub fn reset_active_append_to_initial(&mut self)

Restore the startup append selected by the first Select.ini entry, matching tnm_scene_proc_restart_from_menu_scene().

Source

pub fn has_active_custom_mouse_cursor(&mut self) -> bool

Source

pub fn lookup_scene_no(&self, scene_name: &str) -> Result<i64>

Source

pub fn reset_for_scene_restart(&mut self)

Reinitialize scene-local engine state.

This mirrors C_tnm_eng::reinit_local(true): local flag banks and render/input/sound objects are rebuilt, while global G/Z/M flags, global names, read flags, loaded configuration, global save state and the active append survive. The previous implementation replaced the entire GlobalState, which was equivalent to calling init_global() on every scene restart and destroyed data that the original engine retains.

Source

pub fn set_external_form_handler( &mut self, h: Option<Arc<dyn ExternalFormHandler>>, )

Install or clear an external form handler.

Source

pub fn platform_shortcuts_blocked(&self) -> bool

Source

pub fn on_key_down(&mut self, k: VmKey)

Source

pub fn on_key_up(&mut self, k: VmKey)

Source

pub fn on_text_input(&mut self, text: &str)

Source

pub fn on_ime_preedit(&mut self, text: &str, cursor: Option<(usize, usize)>)

Source

pub fn on_ime_disabled(&mut self)

Source

pub fn editbox_accepts_keyboard_input(&self) -> bool

Source

pub fn editbox_accepts_direct_text(&self) -> bool

Source

pub fn focused_editbox_ime_area(&self) -> Option<(i32, i32, i32, i32)>

Source

pub fn on_mouse_move(&mut self, x: i32, y: i32)

Source

pub fn on_mouse_down(&mut self, b: VmMouseButton)

Source

pub fn on_mouse_up(&mut self, b: VmMouseButton)

Source

pub fn on_mouse_wheel(&mut self, delta_y: i32)

Source

pub fn begin_input_frame(&mut self)

Source

pub fn begin_frame_main_proc_pass(&mut self)

Mark the start of one C++-style frame_main_proc script pass.

Source

pub fn wait_poll(&mut self) -> bool

Source

pub fn push(&mut self, v: Value)

Source

pub fn pop(&mut self) -> Option<Value>

Source

pub fn set_native_ui_backend( &mut self, backend: Option<Arc<dyn NativeUiBackend>>, )

Source

pub fn game_title(&self) -> String

Return the game title for platform UI and runtime dialogs.

The value is read from Gameexe GAMENAME when available. If Gameexe is missing, undecodable, or the field is empty, this returns the project directory name, then Siglus as the final fallback.

Source

pub fn game_name(&self) -> String

Return the game display name for bundle/mobile UI.

Source

pub fn game_display_info(&self) -> GameDisplayInfo

Return display metadata for platform UI.

If the game directory contains cover.png, cover.jpg, cover.jpeg, thumbnail.png, or icon.png, cover is populated. Otherwise callers should display the game name.

Source

pub fn game_cover(&self) -> Option<GameCover>

Return the optional cover for bundle/mobile UI.

Source

pub fn submit_native_messagebox_result(&mut self, request_id: u64, value: i64)

Source

pub fn request_system_messagebox( &mut self, kind: i32, debug_only: bool, text: String, buttons: Vec<SystemMessageBoxButton>, )

Source

pub fn request_system_messagebox_no_return( &mut self, kind: i32, debug_only: bool, text: String, buttons: Vec<SystemMessageBoxButton>, )

Source

pub fn request_internal_system_messagebox_no_return( &mut self, kind: i32, debug_only: bool, text: String, buttons: Vec<SystemMessageBoxButton>, )

Show an engine-rendered modal without delegating to a platform-native message box. Syscom’s built-in fallback menus use this path because they are multi-step in-game UI and must behave identically on every winit target.

Source

pub fn request_chihaya_bench_dialog(&mut self, text: String)

eng_chihaya.cpp::tnm_open_chihaya_bench_dialog(). The original call does not return to the script until the modal information window closes.

Source

pub fn set_screen_size(&mut self, w: u32, h: u32)

Source

pub fn tick_frame(&mut self)

Source

pub fn set_frame_capture_backend( &mut self, backend: Option<FrameCaptureBackendRef>, )

Source

pub fn render_frame_with_effects(&mut self) -> RenderFrame

Source

pub fn render_list_with_effects(&mut self) -> Vec<RenderSprite>

Compatibility/debug flattening. Actual presentation uses RenderFrame and never rasterizes a stage on the CPU.

Source

pub fn debug_active_texture_entries( &self, submitted: &[RenderSprite], ) -> Vec<DebugActiveTextureEntry>

Source

pub fn capture_frame_rgba(&mut self) -> Result<RgbaImage>

Capture the current frame through the same wgpu render graph as presentation.

Source

pub fn capture_frame_rgba_until( &mut self, end_order: i64, end_layer: i64, ) -> Result<RgbaImage>

Capture only sprites up to the original engine order/layer cut line.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<S> FromSample<S> for S

§

fn from_sample_(s: S) -> S

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

§

fn into_sample(self) -> T

§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

§

fn to_sample_(self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more