Skip to content
Snippets Groups Projects
Commit 24b65507 authored by Tim Huppertz's avatar Tim Huppertz
Browse files

Resized kangaroo images.

parent 6ded8773
No related branches found
No related tags found
No related merge requests found
......@@ -27,11 +27,14 @@ from datetime import datetime
from PyQt4 import uic
from ConfigParser import ConfigParser
from koalaConfig import KoalaConfig
import pickle
import os
class Koala():
def __init__(self):
self.dir = os.path.join(os.path.expanduser('~'), ".deskoala")
if not os.path.exists(self.dir):
os.mkdir(self.dir)
self.happiness = 50
self.hunger = 10
self.exhaustion = 10
......@@ -43,6 +46,8 @@ class Koala():
self.name = "Tim"
self.animal = "koala"
self.load()
def get_mood(self):
if datetime.now() > datetime.strptime(datetime.now().strftime("%d.%m.%Y") + " " + self.brushtime, "%d.%m.%Y %H:%M") and self.brushed < datetime.strptime(datetime.now().strftime("%d.%m.%Y") + " " + self.brushtime, "%d.%m.%Y %H:%M"):
return "dirty-teeth"
......@@ -87,9 +92,54 @@ class Koala():
if self.exhaustion < 30:
self.exhaustion += 0.5
f = open(os.path.expanduser(os.path.join("~", ".deskoala", "state.dat")), "wb")
pickle.dump(self, f)
f.close()
self.save()
def save(self):
cfg = os.path.join(self.dir, "koala.ini")
cfgParser = ConfigParser()
cfgParser.add_section('koala')
cfgParser.add_section('behaviour')
cfgParser.add_section('state')
cfgParser.set('koala', 'name', self.name)
cfgParser.set('koala', 'animal', self.animal)
cfgParser.set('behaviour', 'brushtime', self.brushtime)
cfgParser.set('state', 'happiness', self.happiness)
cfgParser.set('state', 'hunger', self.hunger)
cfgParser.set('state', 'exhaustion', self.exhaustion)
cfgParser.set('state', 'brushed', self.brushed.strftime("%d.%m.%Y %H:%M:%S"))
cfgParser.set('state', 'dirtiness', self.dirtiness)
cfgParser.set('state', 'loneliness', self.loneliness)
cfgParser.set('state', 'weight', self.weight)
cfgFile = open(cfg, "w")
cfgParser.write(cfgFile)
cfgFile.close()
def load(self):
cfg = os.path.join(self.dir, "koala.ini")
if os.path.exists(cfg):
cfgParser = ConfigParser()
cfgFile = open(cfg)
cfgParser.readfp(cfgFile)
self.name = cfgParser.get('koala', 'name')
self.animal = cfgParser.get('koala', 'animal')
self.brushtime = cfgParser.get('behaviour', 'brushtime')
self.happiness = float(cfgParser.get('state', 'happiness'))
self.hunger = float(cfgParser.get('state', 'hunger'))
self.exhaustion = float(cfgParser.get('state', 'exhaustion'))
self.brushed = datetime.strptime(cfgParser.get('state', 'brushed'), "%d.%m.%Y %H:%M:%S")
self.dirtiness = float(cfgParser.get('state', 'dirtiness'))
self.loneliness = float(cfgParser.get('state', 'loneliness'))
self.weight = float(cfgParser.get('state', 'weight'))
cfgFile.close()
else:
self.save()
def feed(self):
self.hunger -= 2
......@@ -141,32 +191,9 @@ class Deskoala(plasmascript.Applet):
def __init__(self,parent,args=None):
plasmascript.Applet.__init__(self,parent)
self.dir = os.path.join(os.path.expanduser('~'), ".deskoala")
if not os.path.exists(self.dir):
os.mkdir(self.dir)
try:
f = open(os.path.expanduser(os.path.join("~", ".deskoala", "state.dat")), "rb")
self.koala = pickle.load(f)
f.close()
except:
self.koala = Koala()
self.koala = Koala()
def init(self):
cfg = os.path.join(self.dir, "config.ini")
if os.path.exists(cfg):
cfgParser = ConfigParser()
cfgFile = open(cfg)
cfgParser.readfp(cfgFile)
self.koala.name = cfgParser.get('koala', 'name')
self.koala.animal = cfgParser.get('koala', 'animal')
self.koala.brushtime = cfgParser.get('behaviour', 'brushtime')
cfgFile.close()
else:
self.save_config()
self.setHasConfigurationInterface(True)
self.resize(280, 240)
self.setAspectRatioMode(Plasma.Square)
......@@ -185,21 +212,6 @@ class Deskoala(plasmascript.Applet):
self.layout.addItem(self.buttons)
self.startTimer(5000)
def save_config(self):
cfg = os.path.join(self.dir, "config.ini")
cfgParser = ConfigParser()
cfgParser.add_section('koala')
cfgParser.add_section('behaviour')
cfgParser.set('koala', 'name', self.koala.name)
cfgParser.set('koala', 'animal', self.koala.animal)
cfgParser.set('behaviour', 'brushtime', self.koala.brushtime)
cfgFile = open(cfg, "w")
cfgParser.write(cfgFile)
cfgFile.close()
def createConfigurationInterface(self,parent):
self.koalaConfig = KoalaConfig(self)
page = parent.addPage(self.koalaConfig,"")
......@@ -227,7 +239,7 @@ class Deskoala(plasmascript.Applet):
self.koala.name = self.koalaConfig.linName.text()
self.koala.brushtime = str(self.koalaConfig.timBrushtime.time().toString("h:m"))
self.koala.animal = self.koalaConfig.cmbAnimal.currentText()
self.save_config()
self.koala.save()
def configDenied(self):
pass
......
contents/images/button_brush.gif

113 B | W: | H:

contents/images/button_brush.gif

136 B | W: | H:

contents/images/button_brush.gif
contents/images/button_brush.gif
contents/images/button_brush.gif
contents/images/button_brush.gif
  • 2-up
  • Swipe
  • Onion skin
contents/images/kangaroo_dirty-teeth.gif

238 B | W: | H:

contents/images/kangaroo_dirty-teeth.gif

1.73 KiB | W: | H:

contents/images/kangaroo_dirty-teeth.gif
contents/images/kangaroo_dirty-teeth.gif
contents/images/kangaroo_dirty-teeth.gif
contents/images/kangaroo_dirty-teeth.gif
  • 2-up
  • Swipe
  • Onion skin
contents/images/kangaroo_dirty.gif

266 B | W: | H:

contents/images/kangaroo_dirty.gif

2.17 KiB | W: | H:

contents/images/kangaroo_dirty.gif
contents/images/kangaroo_dirty.gif
contents/images/kangaroo_dirty.gif
contents/images/kangaroo_dirty.gif
  • 2-up
  • Swipe
  • Onion skin
contents/images/kangaroo_fat.gif

251 B | W: | H:

contents/images/kangaroo_fat.gif

1.91 KiB | W: | H:

contents/images/kangaroo_fat.gif
contents/images/kangaroo_fat.gif
contents/images/kangaroo_fat.gif
contents/images/kangaroo_fat.gif
  • 2-up
  • Swipe
  • Onion skin
contents/images/kangaroo_hungry.gif

236 B | W: | H:

contents/images/kangaroo_hungry.gif

1.75 KiB | W: | H:

contents/images/kangaroo_hungry.gif
contents/images/kangaroo_hungry.gif
contents/images/kangaroo_hungry.gif
contents/images/kangaroo_hungry.gif
  • 2-up
  • Swipe
  • Onion skin
contents/images/kangaroo_lonely.gif

236 B | W: | H:

contents/images/kangaroo_lonely.gif

1.7 KiB | W: | H:

contents/images/kangaroo_lonely.gif
contents/images/kangaroo_lonely.gif
contents/images/kangaroo_lonely.gif
contents/images/kangaroo_lonely.gif
  • 2-up
  • Swipe
  • Onion skin
contents/images/kangaroo_neutral.gif

237 B | W: | H:

contents/images/kangaroo_neutral.gif

1.74 KiB | W: | H:

contents/images/kangaroo_neutral.gif
contents/images/kangaroo_neutral.gif
contents/images/kangaroo_neutral.gif
contents/images/kangaroo_neutral.gif
  • 2-up
  • Swipe
  • Onion skin
contents/images/kangaroo_sick.gif

268 B | W: | H:

contents/images/kangaroo_sick.gif

2.11 KiB | W: | H:

contents/images/kangaroo_sick.gif
contents/images/kangaroo_sick.gif
contents/images/kangaroo_sick.gif
contents/images/kangaroo_sick.gif
  • 2-up
  • Swipe
  • Onion skin
contents/images/kangaroo_tired.gif

264 B | W: | H:

contents/images/kangaroo_tired.gif

2.17 KiB | W: | H:

contents/images/kangaroo_tired.gif
contents/images/kangaroo_tired.gif
contents/images/kangaroo_tired.gif
contents/images/kangaroo_tired.gif
  • 2-up
  • Swipe
  • Onion skin
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment