-
Notifications
You must be signed in to change notification settings - Fork 0
/
workbench.py.20140117
executable file
·731 lines (597 loc) · 31.4 KB
/
workbench.py.20140117
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
#!/usr/bin/python3
# -*- coding: utf-8 -*-
#
# AmigaNG Workbench 3.1
# Version 0.3
# (c) 2014 - 2024
# by Wolfgang Schuster
import os
import time
import pygame
import psutil
from pygame.locals import (
K_UP,
K_DOWN,
K_LEFT,
K_RIGHT,
K_ESCAPE,
K_RETURN,
KEYDOWN,
QUIT,
)
pygame.init()
pygame.joystick.init()
width = 800
height = 600
if not pygame.font: print('Fehler pygame.font Modul konnte nicht geladen werden!')
menuefont = pygame.font.Font("fonts/AmigaTopaz.ttf", 15)
iconfont = pygame.font.Font("fonts/AmigaTopaz.ttf", 15)
font = pygame.font.Font("fonts/AmigaTopaz.ttf", 15)
class appicon:
def __init__(self, name, typ, surface, pos, befehl, image, image2):
self.typ = typ
self.name = name
self.surface = surface
self.pos = pos
self.befehl = befehl
self.image = pygame.image.load(image)
self.image2 = pygame.image.load(image2)
self.clicked = False
self.rect = pygame.Rect(0,0,0,0)
def ausgabe(self, font):
icon = pygame.Surface((self.image.get_width()+10,self.image.get_height()+6))
icon.fill((170, 170, 170))
if self.clicked:
pygame.draw.line(icon, (255,255,255), [icon.get_width()-1,0], [icon.get_width()-1,icon.get_height()-1], 1)
pygame.draw.line(icon, (255,255,255), [0, icon.get_height()-2], [icon.get_width()-1,icon.get_height()-2], 2)
pygame.draw.line(icon, (0,0,0), [0, 0], [icon.get_width()-1,0], 2)
pygame.draw.line(icon, (0,0,0), [0, 0], [0,icon.get_height()-1], 1)
icon.blit(self.image2,(5,5))
else:
pygame.draw.line(icon, (0,0,0), [icon.get_width()-1,0], [icon.get_width()-1,icon.get_height()-1], 1)
pygame.draw.line(icon, (0,0,0), [0, icon.get_height()-2], [icon.get_width()-1,icon.get_height()-2], 2)
pygame.draw.line(icon, (255,255,255), [0, 0], [icon.get_width()-1,0], 2)
pygame.draw.line(icon, (255,255,255), [0, 0], [0,icon.get_height()-1], 1)
icon.blit(self.image,(5,3))
self.rect = self.surface.blit(icon, self.pos)
text = font.render(self.name, True, (0, 0, 0))
self.surface.blit(text, (self.pos[0]+icon.get_width()/2-text.get_width()/2,self.pos[1]+icon.get_height()+3))
def checkclicked(self, mousepos):
if self.rect.collidepoint(mousepos):
self.clicked=True
else:
self.clicked=False
class fenster:
def __init__(self, typ, fenstername, fensterrect):
self.typ = typ
self.fensterrect = fensterrect
self.savefensterrect = pygame.Rect(0,0,0,0)
self.savefensterrect.x = self.fensterrect.x
self.savefensterrect.y = self.fensterrect.y
self.savefensterrect.w = self.fensterrect.w
self.savefensterrect.h = self.fensterrect.h
self.outfensterrect = pygame.Rect(self.fensterrect.x-4,self.fensterrect.y-22,self.fensterrect.w+21,self.fensterrect.h+25)
self.surface = pygame.Surface((self.fensterrect.w+25, self.fensterrect.h+47))
self.fenstername = fenstername
self.aktiv = True
self.farbe = (0,0,0)
self.hinweistext = []
self.icons = []
self.verschieben = False
self.fenstercloserect = (0,0,0,0)
self.fenstertoprect = (0,0,0,0)
self.fenstervollrect = (0,0,0,0)
self.fensterfrontrect = (0,0,0,0)
self.fenstersizerect = (0,0,0,0)
self.fensterokrect = (0,0,0,0)
self.fenstercancelrect = (0,0,0,0)
def ausgabe(self, screen, font):
if self.aktiv:
self.farbe = (102,136,187)
else:
self.farbe = (170,170,170)
pygame.draw.rect(screen, (170, 170, 170), self.fensterrect, 0)
# Top
pygame.draw.rect(screen, self.farbe, (self.fensterrect.x-4,self.fensterrect.y-20,self.fensterrect.w+22,18), 0)
pygame.draw.rect(screen, (0,0,0), (self.fensterrect.x-3,self.fensterrect.y-2,self.fensterrect.w+21,2), 0)
pygame.draw.rect(screen, (255,255,255), (self.fensterrect.x-4,self.fensterrect.y-22,self.fensterrect.w+22,2), 0)
pygame.draw.rect(screen, (0,0,0), (self.fensterrect.x-3,self.fensterrect.y-2,self.fensterrect.w+21,2), 0)
if self.typ != "hinweis" and self.typ != "verlassen":
pygame.draw.line(screen, (0,0,0), [self.fensterrect.x+16, self.fensterrect.y-20], [self.fensterrect.x+16, self.fensterrect.y-3], 1)
pygame.draw.line(screen, (255,255,255), [self.fensterrect.x+17, self.fensterrect.y-20], [self.fensterrect.x+17, self.fensterrect.y-3], 1)
pygame.draw.line(screen, (0,0,0), [self.fensterrect.x+self.fensterrect.w-33, self.fensterrect.y-20], [self.fensterrect.x+self.fensterrect.w-33, self.fensterrect.y-3], 1)
pygame.draw.line(screen, (255,255,255), [self.fensterrect.x+self.fensterrect.w-32, self.fensterrect.y-20], [self.fensterrect.x+self.fensterrect.w-32, self.fensterrect.y-3], 1)
pygame.draw.rect(screen, (0,0,0), (self.fensterrect.x+3,self.fensterrect.y-15,7,9), 0)
pygame.draw.rect(screen, (255,255,255), (self.fensterrect.x+5,self.fensterrect.y-13,3,5), 0)
pygame.draw.rect(screen, (0,0,0), (self.fensterrect.x+self.fensterrect.w-27,self.fensterrect.y-18,15,14), 0)
pygame.draw.rect(screen, self.farbe, (self.fensterrect.x+self.fensterrect.w-26,self.fensterrect.y-16,13,10), 0)
pygame.draw.rect(screen, (0,0,0), (self.fensterrect.x+self.fensterrect.w-27,self.fensterrect.y-17,8,7), 0)
pygame.draw.rect(screen, (255,255,255), (self.fensterrect.x+self.fensterrect.w-25,self.fensterrect.y-16,4,4), 0)
self.update()
pygame.draw.line(screen, (0,0,0), [self.fensterrect.x+self.fensterrect.w-8, self.fensterrect.y-20], [self.fensterrect.x+self.fensterrect.w-8, self.fensterrect.y-3], 1)
pygame.draw.line(screen, (255,255,255), [self.fensterrect.x+self.fensterrect.w-7, self.fensterrect.y-20], [self.fensterrect.x+self.fensterrect.w-7, self.fensterrect.y-3], 1)
pygame.draw.rect(screen, (0,0,0), (self.fensterrect.x+self.fensterrect.w-4,self.fensterrect.y-18,13,10), 0)
pygame.draw.rect(screen, (170,170,170), (self.fensterrect.x+self.fensterrect.w-3,self.fensterrect.y-16,11,6), 0)
pygame.draw.rect(screen, (0,0,0), (self.fensterrect.x+self.fensterrect.w+1,self.fensterrect.y-14,13,10), 0)
pygame.draw.rect(screen, (255,255,255), (self.fensterrect.x+self.fensterrect.w+2,self.fensterrect.y-12,11,6), 0)
self.update()
# Left
pygame.draw.rect(screen, self.farbe, (self.fensterrect.x-3,self.fensterrect.y,3,self.fensterrect.h+2), 0)
pygame.draw.rect(screen, (255,255,255), (self.fensterrect.x-4,self.fensterrect.y-22,1,self.fensterrect.h+24), 0)
pygame.draw.rect(screen, (0,0,0), (self.fensterrect.x-1,self.fensterrect.y,1,self.fensterrect.h), 0)
# Bottom
pygame.draw.rect(screen, (255,255,255), (self.fensterrect.x,self.fensterrect.y+self.fensterrect.h,self.fensterrect.w+17,2), 0)
pygame.draw.rect(screen, (0,0,0), (self.fensterrect.x-4,self.fensterrect.y+self.fensterrect.h+2,self.fensterrect.w+21,2), 0)
# Right
if self.typ == "hinweis" or self.typ == "verlassen":
pygame.draw.rect(screen, self.farbe, (self.fensterrect.x+self.fensterrect.w+15,self.fensterrect.y,2,self.fensterrect.h+2), 0)
pygame.draw.rect(screen, (255,255,255), (self.fensterrect.x+14+self.fensterrect.w,self.fensterrect.y,1,self.fensterrect.h+2), 0)
pygame.draw.rect(screen, (0,0,0), (self.fensterrect.x+self.fensterrect.w+17,self.fensterrect.y-20,1,self.fensterrect.h+24), 0)
else:
pygame.draw.rect(screen, self.farbe, (self.fensterrect.x+self.fensterrect.w+1,self.fensterrect.y,16,self.fensterrect.h+2), 0)
pygame.draw.rect(screen, (255,255,255), (self.fensterrect.x+self.fensterrect.w,self.fensterrect.y,1,self.fensterrect.h+2), 0)
pygame.draw.rect(screen, (0,0,0), (self.fensterrect.x+self.fensterrect.w+17,self.fensterrect.y-20,1,self.fensterrect.h+24), 0)
pygame.draw.rect(screen, (255,255,255), (self.fensterrect.x+self.fensterrect.w,self.fensterrect.y+self.fensterrect.h-15,17,2), 0)
pygame.draw.rect(screen, (0,0,0), (self.fensterrect.x+self.fensterrect.w+4,self.fensterrect.y+self.fensterrect.h-10,10,10), 0)
pygame.draw.rect(screen, (255,255,255), (self.fensterrect.x+self.fensterrect.w+5,self.fensterrect.y+self.fensterrect.h-9,8,7), 0)
pygame.draw.line(screen, (0,0,0), [self.fensterrect.x+self.fensterrect.w+4, self.fensterrect.y+self.fensterrect.h-2], [self.fensterrect.x+self.fensterrect.w+12, self.fensterrect.y+self.fensterrect.h-10], 2)
pygame.draw.line(screen, self.farbe, [self.fensterrect.x+self.fensterrect.w+3, self.fensterrect.y+self.fensterrect.h-3], [self.fensterrect.x+self.fensterrect.w+12, self.fensterrect.y+self.fensterrect.h-12], 4)
pygame.draw.rect(screen, self.farbe, (self.fensterrect.x+self.fensterrect.w+4,self.fensterrect.y+self.fensterrect.h-10,5,5), 0)
for icon in self.icons:
icon.ausgabe(font)
tmptext = self.fenstername
fenstertext = font.render(tmptext, True, (0, 0, 0))
if self.typ == "hinweis" or self.typ == "verlassen":
screen.blit(fenstertext,(self.fensterrect.x,self.fensterrect.y-19))
else:
screen.blit(fenstertext,(self.fensterrect.x+22,self.fensterrect.y-19))
if self.typ == "hinweis" or self.typ == "verlassen":
pygame.draw.rect(screen, (225,225,225), (self.fensterrect.x,self.fensterrect.y,self.fensterrect.w+14,self.fensterrect.h), 0)
pygame.draw.rect(screen, (170,170,170), (self.fensterrect.x+5,self.fensterrect.y+5,self.fensterrect.w+4,self.fensterrect.h-44), 0)
pygame.draw.line(screen, (0,0,0), [self.fensterrect.x+6, self.fensterrect.y+5], [self.fensterrect.x+6, self.fensterrect.y+self.fensterrect.h-40], 1)
pygame.draw.line(screen, (255,255,255), [self.fensterrect.x+self.fensterrect.w+8, self.fensterrect.y+5], [self.fensterrect.x+self.fensterrect.w+8, self.fensterrect.y+self.fensterrect.h-40], 1)
pygame.draw.line(screen, (0,0,0), [self.fensterrect.x+6, self.fensterrect.y+5], [self.fensterrect.x+self.fensterrect.w+8, self.fensterrect.y+5], 1)
pygame.draw.line(screen, (255,255,255), [self.fensterrect.x+6, self.fensterrect.y+self.fensterrect.h-40], [self.fensterrect.x+self.fensterrect.w+8, self.fensterrect.y+self.fensterrect.h-40], 1)
if self.typ == "hinweis" or self.typ == "verlassen":
# OK-Button
tmptext = "OK"
buttonwidth = 30
buttonheight = 20
if self.typ == "hinweis":
buttonposx = self.fensterrect.x+(self.fensterrect.w+14)/2-buttonwidth/2
elif self.typ == "verlassen":
buttonposx = self.fensterrect.x+6
buttonposy = self.fensterrect.y+self.fensterrect.h-30
pygame.draw.rect(screen, (255,255,255), (buttonposx-1,buttonposy-1,buttonwidth+2,buttonheight+2), 0)
pygame.draw.rect(screen, (0,0,0), (buttonposx,buttonposy,buttonwidth+1,buttonheight+1), 0)
self.fensterokrect = pygame.draw.rect(screen, (170,170,170), (buttonposx,buttonposy,buttonwidth,buttonheight), 0)
buttontext = font.render(tmptext, True, (0, 0, 0))
screen.blit(buttontext,((buttonposx+buttonwidth/2-buttontext.get_width()/2,buttonposy+buttonheight/2-buttontext.get_height()/2)))
i = 0
for htext in self.hinweistext:
tmptext = htext
hinweistext = font.render(tmptext, True, (0, 0, 0))
if self.typ == "verlassen":
screen.blit(hinweistext,(self.fensterrect.x+(self.fensterrect.w+14)/2-hinweistext.get_width()/2,self.fensterrect.y+10+i*(hinweistext.get_height()+2)))
elif self.typ == "hinweis":
screen.blit(hinweistext,(self.fensterrect.x+24,self.fensterrect.y+16+i*(hinweistext.get_height()+2)))
i = i + 1
if self.typ == "verlassen":
# Cancle-Button
tmptext = "ABBRECHEN"
buttonwidth = 80
buttonheight = 20
buttonposx = self.fensterrect.x+self.fensterrect.w+14-buttonwidth-6
buttonposy = self.fensterrect.y+self.fensterrect.h-30
pygame.draw.rect(screen, (255,255,255), (buttonposx-1,buttonposy-1,buttonwidth+2,buttonheight+2), 0)
pygame.draw.rect(screen, (0,0,0), (buttonposx,buttonposy,buttonwidth+1,buttonheight+1), 0)
self.fenstercancelrect = pygame.draw.rect(screen, (170,170,170), (buttonposx,buttonposy,buttonwidth,buttonheight), 0)
buttontext = font.render(tmptext, True, (0, 0, 0))
screen.blit(buttontext,((buttonposx+buttonwidth/2-buttontext.get_width()/2,buttonposy+buttonheight/2-buttontext.get_height()/2)))
if self.verschieben==True:
pygame.draw.rect(screen, (255, 0, 0), self.outfensterrect, 2)
print("Verschieben:", self.outfensterrect)
# Debug
# pygame.draw.rect(screen, (255,0,0), (self.fenstervollrect), 0)
return
def update(self):
self.fenstercloserect = (self.fensterrect.x-2,self.fensterrect.y-20,18,18)
self.fenstervollrect = (self.fensterrect.x+self.fensterrect.w-31,self.fensterrect.y-20,23,18)
self.fenstersizerect = (self.fensterrect.x+self.fensterrect.w,self.fensterrect.y+self.fensterrect.h-14,17,15)
self.fenstertoprect = (self.fensterrect.x+18,self.fensterrect.y-20,self.fensterrect.w-51,18)
self.fensterfrontrect = (self.fensterrect.x+self.fensterrect.w-7,self.fensterrect.y-20,23,18)
for icon in self.icons:
print(icon.pos[0] + self.fensterrect.x)
def updateout(self):
self.outfensterrect = pygame.Rect(self.fensterrect.x-4,self.fensterrect.y-22,self.fensterrect.w+21,self.fensterrect.h+25)
def leftmouseclick(self, screen, mousepos, leftclickpos):
if pygame.Rect(self.outfensterrect).collidepoint(leftclickpos) or self.verschieben:
self.aktiv = True
else:
self.aktiv=False
if self.aktiv:
if pygame.Rect(self.fenstercloserect).collidepoint(leftclickpos):
return("close")
elif pygame.Rect(self.fensterokrect).collidepoint(leftclickpos):
if self.typ=="verlassen":
return("exit")
elif self.typ=="hinweis":
return("close")
else:
return("ok")
elif pygame.Rect(self.fenstercancelrect).collidepoint(leftclickpos):
return("close")
elif pygame.Rect(self.fenstervollrect).collidepoint(leftclickpos):
if self.fensterrect==self.savefensterrect:
self.savefensterrect.x = self.fensterrect.x
self.savefensterrect.y = self.fensterrect.y
self.savefensterrect.w = self.fensterrect.w
self.savefensterrect.h = self.fensterrect.h
self.fensterrect.x = 4
self.fensterrect.y = 44
self.fensterrect.w = screen.get_width()-22
self.fensterrect.h = screen.get_height()-64
else:
self.fensterrect.x = self.savefensterrect.x
self.fensterrect.y = self.savefensterrect.y
self.fensterrect.w = self.savefensterrect.w
self.fensterrect.h = self.savefensterrect.h
self.update()
self.updateout()
return("max")
elif pygame.Rect(self.fensterfrontrect).collidepoint(leftclickpos):
print("To Front")
return("front")
elif pygame.Rect(self.fenstertoprect).collidepoint(leftclickpos):
self.verschieben=True
self.outfensterrect.x = mousepos[0]-leftclickpos[0]+self.fensterrect.x-4
self.outfensterrect.y = mousepos[1]-leftclickpos[1]+self.fensterrect.y-22
self.update()
return("top")
return
def main():
menueaktion = ""
meldung = "Amigang Workbench 3.1 (c)2014-2024 Wolfgang Schuster"
screen = pygame.display.set_mode([width, height])
pygame.display.set_caption("Amigang Workbench 3.1")
pygame.mouse.set_visible(1)
#pygame.key.set_repeat(1,30)
anzahljoy = pygame.joystick.get_count()
print("Anzahl Joysticks: ", anzahljoy)
if anzahljoy > 0:
for i in range(anzahljoy):
joystick = pygame.joystick.Joystick(i)
joystick.init()
print("Name: ",joystick.get_name())
numaxes = joystick.get_numaxes()
print("Axes: ",numaxes)
for i in range(numaxes):
print(joystick.get_axis(i))
numhats = joystick.get_numhats()
print("Hats: ", numhats)
print("Buttons: ",joystick.get_numbuttons())
# Icons Workbench
wbicons = []
wbicons.append(appicon("Ram Disk" ,"ramdisk", screen, (40,30), "dir:/home/wolf", "images/fd1.png", "images/fd2.png"))
wbicons.append(appicon("DH0" ,"hd", screen, (20,100), "dir:/home/wolf/dh0", "images/hd1.png", "images/hd2.png"))
wbicons.append(appicon("DH1" ,"hd", screen, (20,170), "dir:/home/wolf/dh1", "images/hd1.png", "images/hd2.png"))
wbicons.append(appicon("Shell" ,"cli", screen, (30,240), "starte:Shell", "images/cli1.png", "images/cli2.png"))
# wbicon = appicon("Ram Disk" ,"ramdisk", screen, (40,30), "dir:/home/wolf", "images/fd1.png", "images/fd1.png")
#Menue Images
menuerechtsoben = pygame.image.load("images/menuerechtsoben.png")
# Menueliste [Name, Menutyp (menue, submenue, subsubmenue),Obermenue,befehl, rect , anzahlsubmenues, id, aktiv]
menue = [["Workbench", "menue", "", "", pygame.Rect(0,0,0,0), 0, 0, True]]
menue.append(["Fenster", "menue", "", "", pygame.Rect(0,0,0,0), 0, 0, True])
menue.append(["Piktogramm", "menue", "", "", pygame.Rect(0,0,0,0), 0, 0, True])
menue.append(["Hilfsmittel", "menue", "", "", pygame.Rect(0,0,0,0), 0, 0, True])
menue.append([" Workbench als Hintergrund", "submenue", "Workbench", "Workbench als Hintergrund", pygame.Rect(0,0,0,0), 0, 0, True])
menue.append(["Befehl ausführen ...", "submenue", "Workbench", "Befehl ausführen", pygame.Rect(0,0,0,0), 0, 0, True])
menue.append(["Bild neu aufbauen", "submenue", "Workbench", "Bild neu aufbauen", pygame.Rect(0,0,0,0), 0, 0, True])
menue.append(["Alles aktualisieren", "submenue", "Workbench", "Alles aktualisieren", pygame.Rect(0,0,0,0), 0, 0, True])
menue.append(["Letzte Meldung anzeigen", "submenue", "Workbench", "Letzte Meldung anzeigen", pygame.Rect(0,0,0,0), 0, 0, True])
menue.append(["Version Copyright", "submenue", "Workbench", "Version Copyright", pygame.Rect(0,0,0,0), 0, 0, True])
menue.append(["Workbench verlassen ...", "submenue", "Workbench", "Workbench verlassen", pygame.Rect(0,0,0,0), 0, 0, True])
menue.append(["neue Schublade", "submenue", "Fenster", "Fenster:neue Schublade", pygame.Rect(0,0,0,0), 0, 0, True])
menue.append(["übergeordete Schublade", "submenue", "Fenster", "Fenster:übergeordete Schublade", pygame.Rect(0,0,0,0), 0, 0, True])
menue.append(["schließen", "submenue", "Fenster", "Fenster:schließen", pygame.Rect(0,0,0,0), 0, 0, True])
menue.append(["aktualisieren", "submenue", "Fenster", "Fenster:aktualisieren", pygame.Rect(0,0,0,0), 0, 0, True])
menue.append(["alles auswählen", "submenue", "Fenster", "Fenster:alles auswählen", pygame.Rect(0,0,0,0), 0, 0, True])
menue.append(["Inhalt aufräumen", "submenue", "Fenster", "Fenster:Inhalt aufräumen", pygame.Rect(0,0,0,0), 0, 0, True])
menue.append(["fixieren >>", "submenue", "Fenster:fixieren", "", pygame.Rect(0,0,0,0), 0, 0, True])
menue.append(["Inhalt anzeigen >>", "submenue", "Fenster:anzeigen", "", pygame.Rect(0,0,0,0), 0, 0, True])
menue.append(["Inhalt auflisten >>", "submenue", "Fenster:auflisten", "", pygame.Rect(0,0,0,0), 0, 0, True])
menue.append(["öffnen", "submenue", "Piktogramm", "Piktogramm:öffnen", pygame.Rect(0,0,0,0), 0, 0, True])
menue.append(["kopieren", "submenue", "Piktogramm", "Piktogramm:kopieren", pygame.Rect(0,0,0,0), 0, 0, True])
menue.append(["umbenennen ...", "submenue", "Piktogramm", "Piktogramm:umbenennen", pygame.Rect(0,0,0,0), 0, 0, True])
menue.append(["Informationen", "submenue", "Piktogramm", "Piktogramm:Informationen", pygame.Rect(0,0,0,0), 0, 0, True])
menue.append(["fixieren", "submenue", "Piktogramm", "Piktogramm:fixieren", pygame.Rect(0,0,0,0), 0, 0, True])
menue.append(["Position freigeben", "submenue", "Piktogramm", "Piktogramm:Position freigeben", pygame.Rect(0,0,0,0), 0, 0, True])
menue.append(["auslagern", "submenue", "Piktogramm", "Piktogramm:auslagern", pygame.Rect(0,0,0,0), 0, 0, True])
menue.append(["zurücklegen", "submenue", "Piktogramm", "Piktogramm:zurücklegen", pygame.Rect(0,0,0,0), 0, 0, True])
menue.append(["-------------------------", "submenue", "Piktogramm", "", pygame.Rect(0,0,0,0), 0, 0, False])
menue.append(["löschen ...", "submenue", "Piktogramm", "Piktogramm:löschen", pygame.Rect(0,0,0,0), 0, 0, True])
menue.append(["Disk formatieren ...", "submenue", "Piktogramm", "disk:Disk formatieren", pygame.Rect(0,0,0,0), 0, 0, True])
menue.append(["Papierkorb leeren", "submenue", "Piktogramm", "Papierkorb leeren", pygame.Rect(0,0,0,0), 0, 0, True])
menue.append(["WB zurücksetzen", "submenue", "Hilfsmittel", "WB zurücksetzen", pygame.Rect(0,0,0,0), 0, 0, True])
menue.append(["des Fensters", "subsubmenue", "fixieren >>", "fixieren des Fensters", pygame.Rect(0,0,0,0), 0, 0, True])
menue.append(["alles", "subsubmenue", "fixieren >>", "alles fixieren", pygame.Rect(0,0,0,0), 0, 0, True])
menue.append(["* Nur Dateien mit Piktogr.", "subsubmenue", "Inhalt anzeigen >>", "Folder:Inhalt Dateien mit Piktogr.", pygame.Rect(0,0,0,0), 0, 0, True])
menue.append(["alle Dateien", "subsubmenue", "Inhalt anzeigen >>", "Folder:Inhalt alles", pygame.Rect(0,0,0,0), 0, 0, True])
menue.append(["als Piktogramm", "subsubmenue", "Inhalt auflisten >>", "Folder:auflisten Piktogramm", pygame.Rect(0,0,0,0), 0, 0, True])
menue.append(["nach Namen", "subsubmenue", "Inhalt auflisten >>", "Folder:auflisten Namen", pygame.Rect(0,0,0,0), 0, 0, True])
menue.append(["nach Datum", "subsubmenue", "Inhalt auflisten >>", "Folder:auflisten Datum", pygame.Rect(0,0,0,0), 0, 0, True])
menue.append(["nach Größe", "subsubmenue", "Inhalt auflisten >>", "Folder:auflisten Größe", pygame.Rect(0,0,0,0), 0, 0, True])
menueid = 1
for menueeintrag in menue:
menueeintrag[6] = menueid
menueid = menueid + 1
for submenueeintrag in menue:
if submenueeintrag[2] == menueeintrag[0]:
menueeintrag[5] = menueeintrag[5] + 1
# for menueeintrag in menue:
# print(menueeintrag)
menuemode = 0
aktivmenue = 0
aktivuntermenuerect = pygame.Rect(0,0,0,0)
aktivuntermenue = 0
aktivsubuntermenuerect = pygame.Rect(0,0,0,0)
aktivsubuntermenue = 0
menueposx = 0
menueposy = 0
befehl = ""
freemem = 0
memtimer = 0
leftclick = False
rightclick = False
leftclickpos = (0,0)
rightclickpos = (0,0)
lastleftclick = time.time()
leftdoppelclick = False
aktivicon = 0
aktivfolder = 0
aktivshell = False
aktivfenster = []
fensterlastpos = (0,0)
workbenchfenster = False
if workbenchfenster==True:
aktivfenster.append(fenster("workbench","Workbench",pygame.Rect(4,44,width-22,height-64)))
aktivfenster[0].icons = wbicons
running = True
while running:
mousepos = pygame.mouse.get_pos()
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
# Tastatur
if event.type == KEYDOWN:
if event.key == K_ESCAPE:
menueaktion = "ESC"
elif event.key == K_RIGHT:
menueaktion = "RIGHT"
elif event.key == K_LEFT:
menueaktion = "LEFT"
elif event.key == K_DOWN:
menueaktion = "DOWN"
elif event.key == K_UP:
menueaktion = "UP"
elif event.key == K_RETURN:
menueaktion = "RETURN"
# Maus
elif event.type == pygame.MOUSEBUTTONUP:
if event.button==1:
leftclick = False
if event.button==3:
rightclick = False
menuemode=1
befehl=""
if aktivsubuntermenue>0:
if menue[aktivsubuntermenue-1][2]==menue[aktivuntermenue-1][0]:
befehl = menue[aktivsubuntermenue-1][3]
elif aktivuntermenue>0:
if menue[aktivuntermenue-1][2]==menue[aktivmenue-1][0]:
befehl = menue[aktivuntermenue-1][3]
print(aktivmenue,aktivuntermenue,aktivsubuntermenue,befehl)
if event.button==1:
menuemode=1
menuemode=1
elif event.type == pygame.MOUSEBUTTONDOWN:
if event.button==1:
leftclick = True
leftclickpos = mousepos
if time.time()-lastleftclick < 0.2:
leftdoppelclick=True
else:
leftdoppelclick=False
lastleftclick = time.time()
if event.button==3:
rightclick = True
rightclickpos = mousepos
menuemode=2
aktivmenue=0
aktivuntermenue=0
aktivsubuntermenue=0
# Joystick
elif event.type == pygame.JOYAXISMOTION:
if event.axis == 0:
if event.value > 0.9:
menueaktion = "RIGHT"
elif event.value < -0.9:
menueaktion = "LEFT"
elif event.axis == 1:
if event.value > 0.9:
menueaktion = "DOWN"
elif event.value < -0.9:
menueaktion = "UP"
elif event.type == pygame.JOYBUTTONDOWN:
if event.button == 0:
menueaktion = "RETURN"
elif event.button == 1:
menueaktion = "ESC"
# Aktionen ausführen
if menueaktion != "":
if menueaktion == "ESC":
running = False
menueaktion = ""
screen.fill((170, 170, 170))
# Desktopicons anzeigen
# wbicon.ausgabe(iconfont)
# if workbenchfenster==False:
for wbicon in wbicons:
wbicon.ausgabe(iconfont)
if leftclick:
wbicon.checkclicked(leftclickpos)
if leftdoppelclick:
if wbicon.rect.collidepoint(mousepos):
befehl = wbicon.befehl
leftdoppelclick = False
# Fenster anzeigen
if len(aktivfenster)>0:
for afenster in aktivfenster:
afenster.ausgabe(screen, iconfont)
# Fenster Mausclick
if len(aktivfenster)>0:
for afenster in aktivfenster:
if leftclick:
aktion = afenster.leftmouseclick(screen, mousepos, leftclickpos)
if aktion == "close":
aktivfenster.remove(afenster)
leftclick=False
elif aktion == "exit":
running=False
else:
if afenster.verschieben:
afenster.fensterrect.x = afenster.outfensterrect.x+4
afenster.fensterrect.y = afenster.outfensterrect.y+22
afenster.verschieben=False
leftclick=False
# Menue anzeige
untermenue=0;
if memtimer==0:
freemem = psutil.virtual_memory()[1]
memtimer = 500
memtimer = memtimer -1
if menuemode == 0:
menuetext = menuefont.render(str(meldung), True, (0, 0, 0))
elif menuemode == 1:
tmptext = "Amiga Workbench " + str(freemem) + " Free RAM"
menuetext = menuefont.render(tmptext, True, (0, 0, 0))
pygame.draw.rect(screen, (255,255,255), [0, 0, width, 20], 0)
pygame.draw.line(screen, (0,0,0), [0, 20], [width, 20], 2)
if menuemode==1:
pygame.draw.line(screen, (0,0,0), [width-1, 2], [width-1, 21], 1)
screen.blit(menuerechtsoben,(width-22,2))
if menuemode == 2:
for menueeintrag in menue:
if menueeintrag[3].split(":")[0] == "Piktogramm":
if aktivicon == 0:
menueeintrag[7] = False
else:
menueeintrag[7] = True
if menueeintrag[3].split(":")[0] == "Fenster":
if aktivfolder == 0:
menueeintrag[7] = False
else:
menueeintrag[7] = True
if menueeintrag[3].split(":")[0] == "disk" :
if aktivicon == 0:
menueeintrag[7] = False
elif icons[aktivicon-1][1]=="disk":
menueeintrag[7] = True
if menueeintrag[3] == "Papierkorb leeren":
if aktivicon == 0:
menueeintrag[7] = False
elif icons[aktivicon-1][1]=="trash":
menueeintrag[7] = True
menueposx = 4
# Menue
for menueeintrag in menue:
menueposy = 2
if menueeintrag[1] == "menue":
menueeintragtext = menuefont.render(menueeintrag[0], True, (0, 0, 0))
menueeintrag[4] = screen.blit(menueeintragtext,(menueposx,menueposy))
if menueeintrag[4].collidepoint(mousepos):
aktivmenue = menueeintrag[6]
if aktivmenue == menueeintrag[6]:
pygame.draw.rect(screen, (0,0,0), (menueeintrag[4].x-2,menueeintrag[4].y-2,menueeintrag[4].w+4,menueeintrag[4].h+4), 0)
menueeintragtext = menuefont.render(menueeintrag[0], True, (255, 255, 255))
menueeintrag[4] = screen.blit(menueeintragtext,(menueposx,menueposy))
aktivuntermenuerect.x = menueeintrag[4].x-2
aktivuntermenuerect.y = menueeintrag[4].y + menueeintrag[4].h
aktivuntermenuerect.w = 240
aktivuntermenuerect.h = menueeintrag[5]*18+8
# Submenue
pygame.draw.rect(screen, (255,255,255), (aktivuntermenuerect), 0)
pygame.draw.rect(screen, (0,0,0), (aktivuntermenuerect), 2)
for submenueeintrag in menue:
if submenueeintrag[2] == menueeintrag[0]:
menueposy = menueposy + menueeintrag[4].h + 2
if submenueeintrag[7]:
menueeintragtext = menuefont.render(submenueeintrag[0], True, (0, 0, 0))
else:
menueeintragtext = menuefont.render(submenueeintrag[0], True, (150, 150, 150))
submenueeintrag[4] = screen.blit(menueeintragtext,(menueposx+4,menueposy+2))
submenueeintrag[4].w = aktivuntermenuerect.w-8
if submenueeintrag[4].collidepoint(mousepos):
aktivuntermenue = submenueeintrag[6]
if aktivuntermenue == submenueeintrag[6] and submenueeintrag[7]:
pygame.draw.rect(screen, (0,0,0), (submenueeintrag[4].x-2,submenueeintrag[4].y-2,submenueeintrag[4].w,submenueeintrag[4].h+4), 0)
menueeintragtext = menuefont.render(submenueeintrag[0], True, (255, 255, 255))
submenueeintrag[4] = screen.blit(menueeintragtext,(menueposx+3,menueposy+1))
if submenueeintrag[5] > 0:
aktivsubuntermenuerect.x = submenueeintrag[4].x+submenueeintrag[4].w
aktivsubuntermenuerect.y = submenueeintrag[4].y + menueeintrag[4].h - 20
aktivsubuntermenuerect.w = 240
aktivsubuntermenuerect.h = submenueeintrag[5]*18+8
# SubSubmenue
pygame.draw.rect(screen, (255,255,255), (aktivsubuntermenuerect), 0)
pygame.draw.rect(screen, (0,0,0), (aktivsubuntermenuerect), 2)
submenueposy = aktivsubuntermenuerect.y + 4
submenueposx = aktivsubuntermenuerect.x + 2
for subsubmenueeintrag in menue:
if subsubmenueeintrag[2] == submenueeintrag[0]:
menueeintragtext = menuefont.render(subsubmenueeintrag[0], True, (0, 0, 0))
subsubmenueeintrag[4] = screen.blit(menueeintragtext,(submenueposx+4,submenueposy+2))
subsubmenueeintrag[4].w = aktivuntermenuerect.w-8
if subsubmenueeintrag[4].collidepoint(mousepos):
aktivsubuntermenue = subsubmenueeintrag[6]
if aktivsubuntermenue == subsubmenueeintrag[6]:
pygame.draw.rect(screen, (0,0,0), (subsubmenueeintrag[4].x,subsubmenueeintrag[4].y-2,subsubmenueeintrag[4].w,subsubmenueeintrag[4].h+4), 0)
menueeintragtext = menuefont.render(subsubmenueeintrag[0], True, (255, 255, 255))
submenueeintrag[4] = screen.blit(menueeintragtext,(submenueposx+3,submenueposy+1))
submenueposy = submenueposy + subsubmenueeintrag[4].h + 2
menueposx = menueposx + menueeintrag[4].w + 8
else:
screen.blit(menuetext,(4,2))
# Befehlsverarbeitung
if befehl != "":
print ("Befehl:", befehl)
if befehl=="Workbench verlassen":
aktivfenster.append(fenster("verlassen","Workbench",pygame.Rect(5,43,200,100)))
aktivfenster[len(aktivfenster)-1].hinweistext = ["Wollen Sie wirklich die"]
aktivfenster[len(aktivfenster)-1].hinweistext.append("Workbench verlassen?")
# running=False
elif befehl=="Letzte Meldung anzeigen":
menuemode=0
elif befehl=="starte:Shell":
aktivfenster.append(fenster("shell","AmigaShell",pygame.Rect(4,120,width-22,280)))
elif befehl=="Version Copyright":
aktivfenster.append(fenster("hinweis","Version",pygame.Rect(10,50,200,160)))
aktivfenster[len(aktivfenster)-1].hinweistext = ["Amigang Workbench 3.1"]
aktivfenster[len(aktivfenster)-1].hinweistext.append("Version 0.3")
aktivfenster[len(aktivfenster)-1].hinweistext.append("(c) 2014-2024")
aktivfenster[len(aktivfenster)-1].hinweistext.append("by Wolfgang Schuster")
elif befehl=="Workbench als Hintergrund":
if workbenchfenster==True:
workbenchfenster=False
aktivfenster.pop(0)
else:
workbenchfenster=True
aktivfenster.append(fenster("workbench","Workbench",pygame.Rect(4,44,width-22,height-64)))
aktivfenster[0].icons.append(appicon("Ram Disk" ,"ramdisk", screen, (40,30), "dir:/home/wolf", "images/fd1.png", "images/fd2.png"))
aktivfenster[0].icons.append(appicon("DH0" ,"hd", screen, (20,100), "dir:/home/wolf/dh0", "images/hd1.png", "images/hd2.png"))
aktivfenster[0].icons.append(appicon("DH1" ,"hd", screen, (20,170), "dir:/home/wolf/dh1", "images/hd1.png", "images/hd2.png"))
aktivfenster[0].icons.append(appicon("Shell" ,"cli", screen, (30,240), "starte:Shell", "images/cli1.png", "images/cli2.png"))
befehl = ""
pygame.display.flip()
pygame.quit()
main()