(
ctx: &mut ScriptContext<'_, API>,
rect: Option<EditorUiRect>,
)
| 4144 | .parse::<usize>() |
| 4145 | .ok() |
| 4146 | } |
| 4147 | |
| 4148 | pub fn inspector_var_component_row(name: &str) -> Option<usize> { |
| 4149 | let rest = name.strip_prefix("inspector_var_")?; |
| 4150 | let (row, component) = rest.split_once('_')?; |
| 4151 | let component = component.strip_suffix("_box")?; |
| 4152 | if !matches!(component, "0" | "1" | "2" | "3") { |
| 4153 | return None; |
| 4154 | } |
| 4155 | row.parse::<usize>().ok() |
| 4156 | } |
| 4157 | |
| 4158 | pub fn set_log<API: ScriptAPI + ?Sized>(ctx: &mut ScriptContext<'_, API>, text: &str) { |
| 4159 | let _ = with_state_mut!(ctx.run, EditorState, ctx.id, |state| { |
| 4160 | state.log = text.to_string(); |
| 4161 | }); |
| 4162 | set_label(ctx, "log_text", text); |
| 4163 | } |
| 4164 | |
| 4165 | pub fn tick_script_schema_reload<API: ScriptAPI + ?Sized>(ctx: &mut ScriptContext<'_, API>) { |
| 4166 | let changed = with_state_mut!(ctx.run, EditorState, ctx.id, |state| { |
| 4167 | if state.script_schema_reload_frames == 0 { |
| 4168 | return false; |
| 4169 | } |
| 4170 | state.script_schema_reload_frames = state.script_schema_reload_frames.saturating_sub(1); |
| 4171 | true |
| 4172 | }) |
| 4173 | .unwrap_or(false); |
| 4174 | if changed { |
| 4175 | let visible = with_state!(ctx.run, EditorState, ctx.id, |state| { |
| 4176 | state.script_schema_reload_frames > 0 |
| 4177 | }).unwrap_or_default(); |
| 4178 | apply_script_reload_popup(ctx, visible); |
| 4179 | } |
| 4180 | } |
| 4181 | |
| 4182 | pub fn apply_script_reload_popup<API: ScriptAPI + ?Sized>( |
no test coverage detected