Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Python_超人
太阳系三体模拟器
提交
c4b029ee
太阳系三体模拟器
项目概览
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看板
提交
c4b029ee
编写于
3月 17, 2023
作者:
三月三net
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
太阳系三体模拟器
上级
e4bbb8cd
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
60 addition
and
6 deletion
+60
-6
simulators/ursina/ui_component.py
simulators/ursina/ui_component.py
+3
-1
simulators/ursina/ursina_event.py
simulators/ursina/ursina_event.py
+12
-0
simulators/ursina/ursina_ui.py
simulators/ursina/ursina_ui.py
+34
-5
simulators/ursina_simulator.py
simulators/ursina_simulator.py
+11
-0
未找到文件。
simulators/ursina/ui_component.py
浏览文件 @
c4b029ee
...
...
@@ -35,9 +35,10 @@ class UiSlider(Slider):
# self.height *= 8/10
class
SwithButton
(
ButtonGroup
):
def
__init__
(
self
,
options
,
default
,
tooltips
=
None
):
super
().
__init__
(
options
,
min_selection
=
1
,
y
=-
1
,
default
=
default
,
super
().
__init__
(
options
,
min_selection
=
1
,
default
=
default
,
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
))
# self.label.scale = 0.8
...
...
@@ -49,6 +50,7 @@ class SwithButton(ButtonGroup):
tooltip
=
Tooltip
(
tooltips
[
i
])
tooltip
.
font
=
UrsinaConfig
.
CN_FONT
button
.
tooltip
=
tooltip
self
.
x
=
-
0.5
class
UiButton
(
Button
):
...
...
simulators/ursina/ursina_event.py
浏览文件 @
c4b029ee
...
...
@@ -19,6 +19,11 @@ class UrsinaEvent:
if
hasattr
(
UrsinaEvent
,
"on_reset_funcs"
):
return
UrsinaEvent
.
on_reset_funcs
=
[]
UrsinaEvent
.
on_searching_bodies_funcs
=
[]
@
staticmethod
def
on_searching_bodies_subscription
(
subscription_name
,
fun
):
UrsinaEvent
.
on_searching_bodies_funcs
.
append
((
subscription_name
,
fun
))
@
staticmethod
def
on_reset_subscription
(
fun
):
...
...
@@ -29,5 +34,12 @@ class UrsinaEvent:
for
f
in
UrsinaEvent
.
on_reset_funcs
:
f
()
@
staticmethod
def
on_searching_bodies
(
**
kwargs
):
results
=
[]
for
subscription_name
,
fun
in
UrsinaEvent
.
on_searching_bodies_funcs
:
results
.
append
((
subscription_name
,
fun
(
**
kwargs
)))
return
results
UrsinaEvent
.
init
()
simulators/ursina/ursina_ui.py
浏览文件 @
c4b029ee
...
...
@@ -7,7 +7,7 @@
# python_version :3.8
# ==============================================================================
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
,
ButtonList
,
destroy
from
ursina.prefabs.first_person_controller
import
FirstPersonController
from
simulators.ursina.ui_component
import
UiSlider
,
SwithButton
,
UiButton
...
...
@@ -55,7 +55,7 @@ class UrsinaUI:
tooltips
=
(
'天体运行无轨迹'
,
'天体运行有拖尾轨迹'
))
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_
searching_bodies
_click
)
self
.
reset_button
=
UiButton
(
text
=
'重置'
,
on_click
=
self
.
on_reset_button_click
)
# button1 = Button(text='Button 1', scale=(0.1, 0.1), position=(-0.1, 0))
...
...
@@ -92,8 +92,11 @@ class UrsinaUI:
self
.
slider_run_speed_factor
,
self
.
slider_control_speed_factor
),
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
)
,
popup
=
True
)
self
.
sec_per_time_switch
.
x
=
-
0.5
self
.
on_off_switch
.
x
=
-
0.2
self
.
on_off_trail
.
x
=
-
0.2
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#wp.panel.scale_x / 2 * wp.scale_x
...
...
@@ -121,8 +124,26 @@ class UrsinaUI:
else
:
UrsinaConfig
.
show_trail
=
False
def
on_point_button_click
(
self
):
pass
def
bodies_button_list_click
(
self
,
item
):
print
(
"select->"
,
item
)
destroy
(
self
.
bodies_button_list
)
def
on_searching_bodies_click
(
self
):
results
=
UrsinaEvent
.
on_searching_bodies
()
if
len
(
results
)
>
0
:
sub_name
,
bodies
=
results
[
0
]
# print(results[0])
button_dict
=
{}
for
body
in
bodies
:
def
callback_action
(
b
=
body
):
self
.
bodies_button_list_click
(
b
)
button_dict
[
body
.
name
]
=
callback_action
self
.
bodies_button_list
=
ButtonList
(
button_dict
,
font
=
UrsinaConfig
.
CN_FONT
,
button_height
=
1.5
)
# self.bodies_button_list.input = self.bodies_button_list_input
def
on_reset_button_click
(
self
):
UrsinaEvent
.
on_reset
()
...
...
@@ -131,9 +152,17 @@ class UrsinaUI:
if
self
.
on_off_switch
.
value
==
self
.
pause_button_text
:
self
.
on_off_switch
.
selected_color
=
color
.
green
application
.
paused
=
True
for
c
in
self
.
wp
.
children
:
if
not
c
.
ignore_paused
:
# c.enabled = True
c
.
disabled
=
False
else
:
self
.
on_off_switch
.
selected_color
=
color
.
red
application
.
paused
=
False
for
c
in
self
.
wp
.
children
:
if
not
c
.
ignore_paused
:
# c.enabled = True
c
.
disabled
=
False
def
on_slider_trail_length_changed
(
self
):
UrsinaConfig
.
trail_length
=
int
(
self
.
slider_trail_length
.
value
)
...
...
simulators/ursina_simulator.py
浏览文件 @
c4b029ee
...
...
@@ -11,6 +11,7 @@ from ursina import Ursina, window, Entity, Grid, Mesh, camera, Text, application
load_texture
,
held_keys
from
ursina.prefabs.first_person_controller
import
FirstPersonController
from
simulators.ursina.ursina_event
import
UrsinaEvent
from
simulators.ursina.ursina_ui
import
UrsinaUI
from
simulators.views.ursina_view
import
UrsinaView
,
UrsinaPlayer
from
simulators.ursina.ursina_config
import
UrsinaConfig
...
...
@@ -56,6 +57,16 @@ class UrsinaSimulator(Simulator):
# planets.append(newPlanet)
# x += cp[i] * 10
UrsinaEvent
.
on_searching_bodies_subscription
(
type
(
self
).
__name__
,
self
.
on_searching_bodies
)
def
on_searching_bodies
(
self
,
**
kwargs
):
views
=
[]
for
view
in
self
.
body_views
:
if
view
.
appeared
:
views
.
append
(
view
)
return
views
def
check_elapsed_time
(
self
):
"""检查时间间隔是否已过"""
now
=
datetime
.
datetime
.
now
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录