[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[adonthell-wastesedge-commits] Release_0-3-1 cfd3652 065/237: Adapted sc
From: |
Kai Sterker |
Subject: |
[adonthell-wastesedge-commits] Release_0-3-1 cfd3652 065/237: Adapted schedules and init scripts to the theme and font manager. |
Date: |
Mon, 25 Jul 2016 18:14:57 +0000 (UTC) |
tag: Release_0-3-1
commit cfd365225a6bc5419125802c7f4a38f815b12659
Author: adondev <adondev>
Commit: adondev <adondev>
Adapted schedules and init scripts to the theme and font manager.
schedules.py is no more needed as bubbles are now available from C++.
---
scripts/init.py | 15 +++
scripts/modules/Makefile.am | 2 +-
scripts/modules/console.py | 9 +-
scripts/modules/ins_modules.py | 3 -
scripts/modules/main_menu.py | 11 ++-
scripts/modules/schedules.py | 198 ---------------------------------------
scripts/schedules/alek.py | 2 +-
scripts/schedules/erek.py | 2 +-
scripts/schedules/frostbloom.py | 2 +-
scripts/schedules/jelom.py | 2 +-
scripts/schedules/oliver.py | 2 +-
scripts/schedules/orloth.py | 4 +-
scripts/schedules/sarin.py | 2 +-
scripts/schedules/silverhair.py | 4 +-
scripts/schedules/talan.py | 2 +-
15 files changed, 37 insertions(+), 223 deletions(-)
diff --git a/scripts/init.py b/scripts/init.py
index ac0e4ea..f458ed9 100755
--- a/scripts/init.py
+++ b/scripts/init.py
@@ -1,3 +1,16 @@
+# The themes and fonts we'll use
+win_manager_add_theme ("original")
+win_manager_add_theme ("silverleaf")
+
+win_manager_add_font ("yellow")
+win_manager_add_font ("red")
+win_manager_add_font ("violet")
+win_manager_add_font ("blue")
+win_manager_add_font ("green")
+win_manager_add_font ("white")
+win_manager_add_font ("original")
+win_manager_add_font ("silverleaf")
+
from main_menu import *
import time
@@ -575,6 +588,8 @@ if retval < 5:
talan.set_action ("action_talk")
talan.stand_north ()
talan.set_schedule ("talan")
+ talan.set_val ("say_something", 0)
+ talan.set_val ("delay", 0)
# -- that's a clone for now
jelom = characters ["Jelom Rasgar"]
diff --git a/scripts/modules/Makefile.am b/scripts/modules/Makefile.am
index 7579961..a05d0b6 100755
--- a/scripts/modules/Makefile.am
+++ b/scripts/modules/Makefile.am
@@ -1,5 +1,5 @@
pkgdatadir = $(gamedatadir)/scripts/modules
-pkgdata_DATA = console.py main_menu.py ins_modules.py schedules.py events.py
+pkgdata_DATA = console.py main_menu.py ins_modules.py events.py
EXTRA_DIST = $(pkgdata_DATA)
diff --git a/scripts/modules/console.py b/scripts/modules/console.py
index 336bb7e..d1d7dc1 100755
--- a/scripts/modules/console.py
+++ b/scripts/modules/console.py
@@ -20,9 +20,9 @@ class console (win_container):
self.py_signal_connect (self.on_destroy, win_event_DESTROY)
self.py_signal_connect (self.on_update, win_event_UPDATE)
- # -- load font and theme
- self.font = win_font (WIN_THEME_ORIGINAL)
- self.theme = win_theme (WIN_THEME_ORIGINAL)
+ # -- get font and theme
+ self.font = win_manager_get_font ("silverleaf")
+ self.theme = win_manager_get_theme ("silverleaf")
self.move (10, 150)
self.resize (300, 80)
@@ -59,9 +59,6 @@ class console (win_container):
def __del__(self):
self.write_history ()
- del self.font
- del self.theme
-
# -- callback for command execution
def on_execute (self):
text = self.entry.text_char ()
diff --git a/scripts/modules/ins_modules.py b/scripts/modules/ins_modules.py
index 178a644..2b97e1c 100755
--- a/scripts/modules/ins_modules.py
+++ b/scripts/modules/ins_modules.py
@@ -5,8 +5,5 @@ from adonthellc import *
# random methods are accessible directly
from random import *
-# schedules module is accessible through "schedules" namespace
-import schedules
-
# events module is accessible through "events" namespace
import events
diff --git a/scripts/modules/main_menu.py b/scripts/modules/main_menu.py
index 9fb5be6..cf70f18 100755
--- a/scripts/modules/main_menu.py
+++ b/scripts/modules/main_menu.py
@@ -19,8 +19,10 @@ class main_menu (win_container):
self.thisown = 0
# load font and theme
- self.font = win_font (WIN_THEME_ORIGINAL)
- self.theme = win_theme (WIN_THEME_ORIGINAL)
+ self.font = win_manager_get_font ("original")
+ ##win_font (WIN_THEME_ORIGINAL)
+ self.theme = win_manager_get_theme ("original")
+ ##win_theme (WIN_THEME_ORIGINAL)
self.enable_save = enable_s
@@ -173,8 +175,9 @@ class main_menu (win_container):
# -- cleanup --
def __del__(self):
- del self.font
- del self.theme
+ pass
+## del self.font
+## del self.theme
# -- Callback to close the window
def on_destroy (self):
diff --git a/scripts/modules/schedules.py b/scripts/modules/schedules.py
deleted file mode 100755
index 169b907..0000000
--- a/scripts/modules/schedules.py
+++ /dev/null
@@ -1,198 +0,0 @@
-#
-# $Id$
-#
-# (C) Copyright 2001 Kai Sterker <address@hidden>
-# Part of the Adonthell Project http://adonthell.linuxgames.com
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License.
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY.
-#
-# See the COPYING file for more details
-#
-
-# Helper functions for usage in schedules
-from adonthell import *
-import random
-
-# -- A function that doesn't deserve the term 'pathfinding'
-def simple_goto_xy (mychar, goal_x, goal_y):
-
- dist_x = mychar.posx () - goal_x
- dist_y = mychar.posy () - goal_y
-
- # -- reached the goal?
- if dist_x == 0 and dist_y == 0:
- # -- wait until we are truly there!
- if mychar.offx () == 0 and mychar.offy () == 0:
- return 1
- else:
- return 0
-
- dst = float (abs(dist_x)) / (abs (dist_x) + abs (dist_y))
- rnd = random.random ()
-
- # -- preferrably walk into the direction that is closest
- # to the goal. But we allow a little variation.
- if rnd > dst:
- go_north_south (mychar, dist_x, dist_y, 1)
- else:
- go_east_west (mychar, dist_x, dist_y, 1)
-
- return 0
-
-
-# -- try to walk in the direction that leads to the goal
-def go_north_south (mychar, dist_x, dist_y, count):
-### Continue current movment if moving
-## if mychar.offx () or mychar.offy ():
-## if mychar.currentmove () == WALK_NORTH:
-## mychar.go_north ()
-## elif mychar.currentmove () == WALK_SOUTH:
-## mychar.go_south ()
-## return
-
- # -- All four directions blocked -> wait a turn
- if count >= 4: return
-
- # -- try to approach goal in y direction first,
- # if blocked, try x direction, and if that's not
- # possible then walk back
- if dist_y <= 0 and mychar.can_go_south ():
- mychar.go_south ()
- elif dist_y >= 0 and mychar.can_go_north ():
- mychar.go_north ()
- else:
- dist_y = -dist_y
- go_east_west (mychar, dist_x, dist_y, count+1)
-
-# -- try to walk in the direction that leads to the goal
-def go_east_west (mychar, dist_x, dist_y, count):
-### Continue current movment if moving
-## if mychar.offx () or mychar.offy ():
-## if mychar.currentmove () == WALK_WEST:
-## mychar.go_west ()
-## elif mychar.currentmove () == WALK_EAST:
-## mychar.go_east ()
-## return
-
- # -- All four directions blocked -> wait a turn
- if count >= 4: return
-
- # -- try to approach goal in x direction first,
- # if blocked, try y direction, and if that's not
- # possible then walk back
- if dist_x >= 0 and mychar.can_go_west ():
- mychar.go_west ()
- elif dist_x <= 0 and mychar.can_go_east ():
- mychar.go_east ()
- else:
- dist_x = -dist_x
- go_north_south (mychar, dist_x, dist_y, count+1)
-
-
-# -- display a "bubble" with some text above a character
-def speak (mychar, text):
- # -- ... but only if he's on the player's submap
- if mychar.submap () == gamedata_player ().submap ():
-
- b = bubble (mychar, text)
- b.thisown = 0
-
- # -- add the bubble to the win_manager, but don't give it the focus
- win_manager_add_after (b, gamedata_map_engine ().get_mapview ())
-
-
-# -- the "bubble"-window
-class bubble (win_container):
- def __init__ (self, mychar, text):
- win_container.__init__(self)
-
- # -- the time the bubble will remain open
- self.remain = 75 + len (text) * 4
-
- self.py_signal_connect (self.on_destroy, win_event_DESTROY)
- self.py_signal_connect (self.on_update, win_event_UPDATE, mychar)
-
- # -- get the font that matches the NPC's text color
- if mychar.get_color () == 1: self.font = win_font ("yellow/")
- elif mychar.get_color () == 2: self.font = win_font ("red/")
- elif mychar.get_color () == 3: self.font = win_font ("violet/")
- elif mychar.get_color () == 4: self.font = win_font ("blue/")
- elif mychar.get_color () == 5: self.font = win_font ("green/")
- else: self.font = win_font( "white/")
-
- self.theme = win_theme (WIN_THEME_ORIGINAL)
-
- # -- if the submap is smaller than the mapview, we have to
- # calculate the offset
- view = gamedata_map_engine ().get_mapview ()
- area = gamedata_map_engine ().get_landmap ().get_submap (mychar.submap
())
- if area.area_length () * MAPSQUARE_SIZE < view.length ():
- self.offx = (view.length () - area.area_length () *
MAPSQUARE_SIZE) / 2
- else:
- self.offx = 0
- if area.area_height () * MAPSQUARE_SIZE < view.height ():
- self.offy = (view.height () - area.area_height () *
MAPSQUARE_SIZE) / 2
- else:
- self.offy = 0
-
- # -- get the postion above the character's head
- x, y = self.get_window_pos (mychar)
-
- self.resize (120, 55)
- self.move (x, y)
-
- self.bubble = win_label ()
- self.bubble.set_font (self.font)
- self.bubble.resize (110, 0)
- self.bubble.set_form (label_AUTO_HEIGHT)
- self.bubble.set_text (text)
-
- x = (self.length () - self.bubble.length ()) / 2
- y = self.height () - self.bubble.height () - 3
-
- self.bubble.move (x, y)
- self.bubble.thisown = 0
- self.bubble.pack()
-
- self.bubble.set_background (self.theme)
- self.bubble.set_visible_background (1)
- self.bubble.set_trans_background (1)
-
- self.bubble.set_border(self.theme, win_border_MINI)
- self.bubble.set_visible_border (1)
-
- self.add (self.bubble)
- self.set_visible_all (1)
-
- def __del__ (self):
- del self.theme
- del self.font
-
- # -- once this returns 0, the bubble will close
- def on_destroy (self):
- return self.remain
-
- # -- draws the bubble above the character's head
- def on_update (self, mychar):
- # -- but only if the map should be updated
- if gamedata_map_engine ().should_update_map ():
- # -- and if on the same submap as the player
- if mychar.submap () == gamedata_player ().submap ():
- x, y = self.get_window_pos (mychar)
- self.move (x, y)
- self.remain = self.remain - 1
- else:
- self.remain = 0
-
- # -- center the window above the characters head
- def get_window_pos (self, mychar):
- view = gamedata_map_engine ().get_mapview ()
- x = (mychar.posx () - view.posx () - mychar.base_x ()) * MAPSQUARE_SIZE
- x = x + mychar.offx () - view.offx () - 55 + self.offx
- y = (mychar.posy () - view.posy () - mychar.base_y ()) * MAPSQUARE_SIZE
- y = y + mychar.offy () - view.offy () - 40 + self.offy
-
- return (x, y)
diff --git a/scripts/schedules/alek.py b/scripts/schedules/alek.py
index 252e4b7..7389ecc 100755
--- a/scripts/schedules/alek.py
+++ b/scripts/schedules/alek.py
@@ -55,6 +55,6 @@ elif todo == 2:
tmp = myself.get_val ("say_something")
myself.set_val ("say_something", tmp - 1)
if tmp == 0:
- schedules.speak (myself, speech[randint (0, 2)])
+ myself.speak (speech[randint (0, 2)])
delay = randint (40, 80) * 25
myself.set_val ("say_something", delay)
diff --git a/scripts/schedules/erek.py b/scripts/schedules/erek.py
index 30170af..17e45ce 100755
--- a/scripts/schedules/erek.py
+++ b/scripts/schedules/erek.py
@@ -115,6 +115,6 @@ tmp = myself.get_val ("say_something")
myself.set_val ("say_something", tmp - 1)
if tmp == 0:
- schedules.speak (myself, speech[randint (0, 2)])
+ myself.speak (speech[randint (0, 2)])
delay = randint (60, 180) * 15
myself.set_val ("say_something", delay)
diff --git a/scripts/schedules/frostbloom.py b/scripts/schedules/frostbloom.py
index 483301a..af9099d 100755
--- a/scripts/schedules/frostbloom.py
+++ b/scripts/schedules/frostbloom.py
@@ -58,6 +58,6 @@ elif todo == 2:
tmp = myself.get_val ("say_something")
myself.set_val ("say_something", tmp - 1)
if tmp == 0:
- schedules.speak (myself, speech[randint (0, 2)])
+ myself.speak (speech[randint (0, 2)])
delay = randint (50, 150) * 20
myself.set_val ("say_something", delay)
diff --git a/scripts/schedules/jelom.py b/scripts/schedules/jelom.py
index 715ce7a..2581f1d 100644
--- a/scripts/schedules/jelom.py
+++ b/scripts/schedules/jelom.py
@@ -53,6 +53,6 @@ elif todo == 2:
tmp = myself.get_val ("say_something")
myself.set_val ("say_something", tmp - 1)
if tmp <= 0:
- schedules.speak (myself, speech[randint (0, 2)])
+ myself.speak (speech[randint (0, 2)])
delay = randint (75, 150) * 20
myself.set_val ("say_something", delay)
diff --git a/scripts/schedules/oliver.py b/scripts/schedules/oliver.py
index 2dc97b2..2bae077 100755
--- a/scripts/schedules/oliver.py
+++ b/scripts/schedules/oliver.py
@@ -104,6 +104,6 @@ tmp = myself.get_val ("say_something")
myself.set_val ("say_something", tmp - 1)
if tmp == 0:
- schedules.speak (myself, speech[randint (0, 2)])
+ myself.speak (speech[randint (0, 2)])
delay = randint (80, 160) * 10
myself.set_val ("say_something", delay)
diff --git a/scripts/schedules/orloth.py b/scripts/schedules/orloth.py
index f58bbac..caaa1d4 100755
--- a/scripts/schedules/orloth.py
+++ b/scripts/schedules/orloth.py
@@ -59,7 +59,7 @@ elif todo == 2:
if myself.follow_path () == 1:
# -- standing in front of the clock
if myself.posx () == 10:
- schedules.speak (myself, "That clock is late again!")
+ myself.speak ("That clock is late again!")
tmp = myself.get_val ("say_something")
myself.set_val ("say_something", tmp + 75)
@@ -71,6 +71,6 @@ elif todo == 2:
tmp = myself.get_val ("say_something")
myself.set_val ("say_something", tmp - 1)
if tmp == 0:
- schedules.speak (myself, speech[randint (0, 2)])
+ myself.speak (speech[randint (0, 2)])
delay = randint (50, 150) * 20
myself.set_val ("say_something", delay)
diff --git a/scripts/schedules/sarin.py b/scripts/schedules/sarin.py
index 11e8fa0..d7ac3aa 100755
--- a/scripts/schedules/sarin.py
+++ b/scripts/schedules/sarin.py
@@ -103,6 +103,6 @@ elif todo == 2:
tmp = myself.get_val ("say_something")
myself.set_val ("say_something", tmp - 1)
if tmp == 0:
- schedules.speak (myself, speech[randint (0, 3)])
+ myself.speak (speech[randint (0, 3)])
delay = randint (50, 150) * 10
myself.set_val ("say_something", delay)
diff --git a/scripts/schedules/silverhair.py b/scripts/schedules/silverhair.py
index bd0c7f6..3944ec6 100755
--- a/scripts/schedules/silverhair.py
+++ b/scripts/schedules/silverhair.py
@@ -61,9 +61,9 @@ say = myself.get_val ("say_something")
myself.set_val ("say_something", say - 1)
if say == 0:
if myself.posx () == 6:
- schedules.speak (myself, speech[3])
+ myself.speak (speech[3])
else:
- schedules.speak (myself, speech[randint (0, 2)])
+ myself.speak (speech[randint (0, 2)])
say = randint (50, 150) * 20
myself.set_val ("say_something", say)
diff --git a/scripts/schedules/talan.py b/scripts/schedules/talan.py
index 5c7307c..67dea0a 100755
--- a/scripts/schedules/talan.py
+++ b/scripts/schedules/talan.py
@@ -53,6 +53,6 @@ elif todo == 2:
tmp = myself.get_val ("say_something")
myself.set_val ("say_something", tmp - 1)
if tmp <= 0:
- schedules.speak (myself, speech[randint (0, 2)])
+ myself.speak (speech[randint (0, 2)])
delay = randint (50, 150) * 20
myself.set_val ("say_something", delay)
- [adonthell-wastesedge-commits] Release_0-3-1 aa2d088 057/237: Added erek and fellnir., (continued)
- [adonthell-wastesedge-commits] Release_0-3-1 aa2d088 057/237: Added erek and fellnir., Kai Sterker, 2016/07/25
- [adonthell-wastesedge-commits] Release_0-3-1 eccdffa 095/237: FIXED installation of follow_character.py, Kai Sterker, 2016/07/25
- [adonthell-wastesedge-commits] Release_0-3-1 0df9cb7 084/237: Continued map forest, Kai Sterker, 2016/07/25
- [adonthell-wastesedge-commits] Release_0-3-1 835df8f 083/237: ADDED Janesta's schedule, Kai Sterker, 2016/07/25
- [adonthell-wastesedge-commits] Release_0-3-1 ee9fc6d 107/237: ADDED remaining portraits, Kai Sterker, 2016/07/25
- [adonthell-wastesedge-commits] Release_0-3-1 836cc1a 077/237: Updated Orloth, Kai Sterker, 2016/07/25
- [adonthell-wastesedge-commits] Release_0-3-1 8461ce1 108/237: FIXED a bug in Orloth's dialogue, Kai Sterker, 2016/07/25
- [adonthell-wastesedge-commits] Release_0-3-1 9da31d1 085/237: OOpps!, Kai Sterker, 2016/07/25
- [adonthell-wastesedge-commits] Release_0-3-1 2b67b8c 096/237: Reorganized the schedules structure, Kai Sterker, 2016/07/25
- [adonthell-wastesedge-commits] Release_0-3-1 11972d6 094/237: *** empty log message ***, Kai Sterker, 2016/07/25
- [adonthell-wastesedge-commits] Release_0-3-1 cfd3652 065/237: Adapted schedules and init scripts to the theme and font manager.,
Kai Sterker <=
- [adonthell-wastesedge-commits] Release_0-3-1 7b03aa9 081/237: Done some map work., Kai Sterker, 2016/07/25
- [adonthell-wastesedge-commits] Release_0-3-1 a49adb1 102/237: Now getting the_player, characters and quests via the proper API functions, Kai Sterker, 2016/07/25
- [adonthell-wastesedge-commits] Release_0-3-1 53eb6ab 113/237: The player is now saved in character.data too, Kai Sterker, 2016/07/25
- [adonthell-wastesedge-commits] Release_0-3-1 ef12728 074/237: Added transition tiles, Kai Sterker, 2016/07/25
- [adonthell-wastesedge-commits] Release_0-3-1 cf1b9c2 093/237: Adapted the game to the new Python engine, Kai Sterker, 2016/07/25
- [adonthell-wastesedge-commits] Release_0-3-1 161f58d 071/237: Improved the dialogues according to the points discussed in Bavinchove, Kai Sterker, 2016/07/25
- [adonthell-wastesedge-commits] Release_0-3-1 13286b8 110/237: UPDATED scripts after removal of map_engine, Kai Sterker, 2016/07/25
- [adonthell-wastesedge-commits] Release_0-3-1 984f397 125/237: Test add, Kai Sterker, 2016/07/25
- [adonthell-wastesedge-commits] Release_0-3-1 0206066 097/237: CHANGED Jeloms dialogue to fit with the new plot, Kai Sterker, 2016/07/25
- [adonthell-wastesedge-commits] Release_0-3-1 a0e6b2a 045/237: Oops! I kept my test files!, Kai Sterker, 2016/07/25