Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Python_超人
太阳系三体模拟器
提交
372ba34d
太阳系三体模拟器
项目概览
Python_超人
/
太阳系三体模拟器
通知
1103
Star
131
Fork
129
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
太阳系三体模拟器
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
372ba34d
编写于
3月 16, 2023
作者:
三月三net
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
太阳系三体模拟器
上级
a4e8bf9e
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
27 addition
and
15 deletion
+27
-15
simulators/ursina/ui_component.py
simulators/ursina/ui_component.py
+9
-4
simulators/ursina/ursina_ui.py
simulators/ursina/ursina_ui.py
+18
-11
未找到文件。
simulators/ursina/ui_component.py
浏览文件 @
372ba34d
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
# python_version :3.8
# python_version :3.8
# ==============================================================================
# ==============================================================================
from
ursina
import
Ursina
,
window
,
Entity
,
Grid
,
Mesh
,
camera
,
Text
,
application
,
color
,
mouse
,
Vec2
,
Vec3
,
\
from
ursina
import
Ursina
,
window
,
Entity
,
Grid
,
Mesh
,
camera
,
Text
,
application
,
color
,
mouse
,
Vec2
,
Vec3
,
\
load_texture
,
held_keys
,
Button
load_texture
,
held_keys
,
Button
,
Tooltip
from
ursina.prefabs.first_person_controller
import
FirstPersonController
from
ursina.prefabs.first_person_controller
import
FirstPersonController
from
simulators.ursina.ursina_config
import
UrsinaConfig
from
simulators.ursina.ursina_config
import
UrsinaConfig
from
simulators.ursina.ursina_event
import
UrsinaEvent
from
simulators.ursina.ursina_event
import
UrsinaEvent
...
@@ -36,14 +36,19 @@ class UiSlider(Slider):
...
@@ -36,14 +36,19 @@ class UiSlider(Slider):
class
SwithButton
(
ButtonGroup
):
class
SwithButton
(
ButtonGroup
):
def
__init__
(
self
,
options
,
default
):
def
__init__
(
self
,
options
,
default
,
tooltips
=
None
):
super
().
__init__
(
options
,
min_selection
=
1
,
y
=
0
,
default
=
default
,
super
().
__init__
(
options
,
min_selection
=
1
,
y
=
0
,
default
=
default
,
selected_color
=
color
.
green
,
ignore_paused
=
True
,
selected_color
=
color
.
rgba
(
0.1
,
0.6
,
0.1
,
1.0
)
,
ignore_paused
=
True
,
color
=
color
.
rgba
(
0.0
,
0.0
,
0.0
,
0.5
))
color
=
color
.
rgba
(
0.0
,
0.0
,
0.0
,
0.5
))
# self.label.scale = 0.8
# self.label.scale = 0.8
# self.label.font = UrsinaConfig.CN_FONT
# self.label.font = UrsinaConfig.CN_FONT
for
button
in
self
.
buttons
:
for
i
,
button
in
enumerate
(
self
.
buttons
)
:
button
.
text_entity
.
font
=
UrsinaConfig
.
CN_FONT
button
.
text_entity
.
font
=
UrsinaConfig
.
CN_FONT
if
tooltips
is
not
None
:
if
len
(
tooltips
)
>
i
:
tooltip
=
Tooltip
(
tooltips
[
i
])
tooltip
.
font
=
UrsinaConfig
.
CN_FONT
button
.
tooltip
=
tooltip
class
UiButton
(
Button
):
class
UiButton
(
Button
):
...
...
simulators/ursina/ursina_ui.py
浏览文件 @
372ba34d
...
@@ -13,15 +13,17 @@ from ursina.prefabs.first_person_controller import FirstPersonController
...
@@ -13,15 +13,17 @@ from ursina.prefabs.first_person_controller import FirstPersonController
from
simulators.ursina.ui_component
import
UiSlider
,
SwithButton
,
UiButton
from
simulators.ursina.ui_component
import
UiSlider
,
SwithButton
,
UiButton
from
simulators.ursina.ursina_config
import
UrsinaConfig
from
simulators.ursina.ursina_config
import
UrsinaConfig
from
simulators.ursina.ursina_event
import
UrsinaEvent
from
simulators.ursina.ursina_event
import
UrsinaEvent
from
ursina
import
WindowPanel
,
InputField
,
Button
,
Slider
,
ButtonGroup
from
ursina
import
WindowPanel
,
InputField
,
Button
,
Slider
,
ButtonGroup
,
Panel
class
UrsinaUI
:
class
UrsinaUI
:
def
ui_component_init
(
self
):
def
ui_component_init
(
self
):
self
.
start_button_text
=
"●"
# 》●▲○◎
self
.
start_button_text
=
"●"
# 》●▲○◎
self
.
pause_button_text
=
"〓"
# 〓 || ‖
self
.
pause_button_text
=
"〓"
# 〓 || ‖
self
.
no_trail_button_text
=
"○ "
self
.
trail_button_text
=
"○--"
application
.
time_scale
=
0.5
application
.
time_scale
=
0.5
self
.
slider_body_spin_factor
=
UiSlider
(
text
=
'自转速度'
,
min
=
0.01
,
max
=
30
,
default
=
1
)
self
.
slider_body_spin_factor
=
UiSlider
(
text
=
'自转速度'
,
min
=
0.01
,
max
=
30
,
default
=
1
)
...
@@ -37,20 +39,27 @@ class UrsinaUI:
...
@@ -37,20 +39,27 @@ class UrsinaUI:
self
.
slider_trail_length
.
on_value_changed
=
self
.
on_slider_trail_length_changed
self
.
slider_trail_length
.
on_value_changed
=
self
.
on_slider_trail_length_changed
self
.
on_off_switch
=
SwithButton
((
self
.
pause_button_text
,
self
.
on_off_switch
=
SwithButton
((
self
.
pause_button_text
,
self
.
start_button_text
),
default
=
self
.
start_button_text
)
self
.
start_button_text
),
default
=
self
.
start_button_text
,
tooltips
=
(
'暂停'
,
'运行'
))
self
.
on_off_switch
.
selected_color
=
color
.
red
self
.
on_off_switch
.
selected_color
=
color
.
red
self
.
on_off_trail
=
SwithButton
((
' '
,
'...'
),
default
=
' '
)
self
.
on_off_trail
=
SwithButton
((
self
.
no_trail_button_text
,
self
.
trail_button_text
),
default
=
self
.
no_trail_button_text
,
tooltips
=
(
'天体运行无轨迹'
,
'天体运行有拖尾轨迹'
))
self
.
on_off_trail
.
on_value_changed
=
self
.
on_off_trail_changed
self
.
on_off_trail
.
on_value_changed
=
self
.
on_off_trail_changed
self
.
point_button
=
UiButton
(
text
=
'寻找'
,
on_click
=
self
.
on_point_button_click
)
self
.
point_button
=
UiButton
(
text
=
'寻找'
,
on_click
=
self
.
on_point_button_click
)
self
.
reset_button
=
UiButton
(
text
=
'重置'
,
on_click
=
self
.
on_reset_button_click
)
self
.
reset_button
=
UiButton
(
text
=
'重置'
,
on_click
=
self
.
on_reset_button_click
)
self
.
on_off_switch
.
on_value_changed
=
self
.
on_off_switch_changed
self
.
point_button
.
scale_x
=
-
0.2
self
.
reset_button
.
scale_x
=
0.2
self
.
on_off_switch
.
on_value_changed
=
self
.
on_off_switch_changed
wp
=
WindowPanel
(
wp
=
WindowPanel
(
title
=
''
,
title
=
''
,
content
=
(
content
=
(
Text
(
'方位控制: Q W E A S D + 鼠标右键'
,
font
=
'msyhl.ttc'
),
Text
(
'方位控制: Q W E A S D + 鼠标右键'
,
font
=
'msyhl.ttc'
),
# InputField(name='name_field'),
# InputField(name='name_field'),
# Button(text='Submit', color=color.azure),
# Button(text='Submit', color=color.azure),
self
.
point_button
,
self
.
point_button
,
...
@@ -66,7 +75,7 @@ class UrsinaUI:
...
@@ -66,7 +75,7 @@ class UrsinaUI:
),
ignore_paused
=
True
,
color
=
color
.
rgba
(
0.0
,
0.0
,
0.0
,
0.5
)
),
ignore_paused
=
True
,
color
=
color
.
rgba
(
0.0
,
0.0
,
0.0
,
0.5
)
)
)
wp
.
y
=
0.5
# wp.panel.scale_y / 2 * wp.scale_y # center the window panel
wp
.
y
=
0.5
# wp.panel.scale_y / 2 * wp.scale_y # center the window panel
wp
.
x
=
0.6
# wp.scale_x + 0.1
wp
.
x
=
0.6
# wp.scale_x + 0.1
# wp.x = 0#wp.panel.scale_x / 2 * wp.scale_x
# wp.x = 0#wp.panel.scale_x / 2 * wp.scale_x
self
.
wp
=
wp
self
.
wp
=
wp
...
@@ -86,10 +95,8 @@ class UrsinaUI:
...
@@ -86,10 +95,8 @@ class UrsinaUI:
# slider_text = Text(text='自转速度', scale=1, position=(-0.6, 0.3))
# slider_text = Text(text='自转速度', scale=1, position=(-0.6, 0.3))
# slider = Slider(scale=0.5, position=(-0.6, 0), min=0, max=10, step=1, text=slider_text)
# slider = Slider(scale=0.5, position=(-0.6, 0), min=0, max=10, step=1, text=slider_text)
def
on_off_trail_changed
(
self
):
def
on_off_trail_changed
(
self
):
if
self
.
on_off_trail
.
value
==
"..."
:
if
self
.
on_off_trail
.
value
==
self
.
trail_button_text
:
UrsinaConfig
.
show_trail
=
True
UrsinaConfig
.
show_trail
=
True
else
:
else
:
UrsinaConfig
.
show_trail
=
False
UrsinaConfig
.
show_trail
=
False
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录