| 1 | /*************************************************************************** |
| 2 | entry.cpp - description |
| 3 | ------------------- |
| 4 | begin : Wed Jan 10 1996 |
| 5 | copyright : (C) 1996 by Waldemar Baraldi |
| 6 | email : [email protected] |
| 7 | ***************************************************************************/ |
| 8 | |
| 9 | /*************************************************************************** |
| 10 | * * |
| 11 | * This program is free software; you can redistribute it and/or modify * |
| 12 | * it under the terms of the GNU General Public License as published by * |
| 13 | * the Free Software Foundation; either version 2 of the License, or * |
| 14 | * (at your option) any later version. * |
| 15 | * * |
| 16 | ***************************************************************************/ |
| 17 | |
| 18 | #include "entry.h" |
| 19 | |
| 20 | Entry::Entry(CardinalPoint connection):Pipe(){ |
| 21 | con=connection; |
| 22 | } |
| 23 | |
| 24 | Entry::~Entry(){} |
| 25 | |
| 26 | bool Entry::hasConnection(CardinalPoint con){ |
| 27 | return (this->con==con); |
| 28 | } |
| 29 | |
| 30 | CardinalPoint Entry::getOutput(CardinalPoint input){ |
| 31 | return con; |
| 32 | } |
| 33 | |
| 34 | void Entry::incFullLevel(CardinalPoint input,unsigned int amount){ |
| 35 | full_level+=amount; |
| 36 | used_input=Void; |
| 37 | } |
| 38 | |
| 39 | int Entry::getFullLevel(CardinalPoint input){ |
| 40 | return this->full_level; |
| 41 | } |
| 42 | |
| 43 | Pointer * Entry::getPointer(){ |
| 44 | return NULL; |
| 45 | } |
| 46 | |
| 47 | bool Entry::isRemovable(){ |
| 48 | return false; |
| 49 | } |
| 50 | |
| 51 | void Entry::paint(VideoManager * vm){ |
| 52 | Image * aux; |
| 53 | Image * ima; |
| 54 | |
| 55 | if (con==East || con==West) |
| 56 | ima=(vm->getImageManager())->getImage(new Str("entry_h.png")); |
| 57 | else |
| 58 | ima=(vm->getImageManager())->getImage(new Str("entry_v.png")); |
| 59 | aux=new Image(ima); |
| 60 | switch (con){ |
| 61 | case South:{aux->flip(HAxis);aux->flip(VAxis);break;} |
| 62 | case West:{aux->flip(VAxis);break;} |
| 63 | default:break; |
| 64 | } |
| 65 | vm->blit(aux, x, y); |
| 66 | delete aux; |
| 67 | |
| 68 | if (full_level>0){ |
| 69 | ima=(vm->getImageManager())->getImage(new Str("flow.png")); |
| 70 | int xof=x+PipeWidth/2-ima->width()/2; |
| 71 | int yof=y+PipeHeight/2-ima->height()/2; |
| 72 | vm->setClipping(x, y, PipeWidth, PipeHeight); |
| 73 | vm->enableClipping(true); |
| 74 | switch (con){ |
| 75 | case North:case South:{ |
| 76 | float factor=0.5*(float)PipeHeight/(float)full(); |
| 77 | if (con==North) factor=-factor; |
| 78 | for (int i=0;i<full_level+Gran;i+=Gran) |
| 79 | vm->blit(ima, xof, (int)(yof+(float)i*factor)); |
| 80 | break; |
| 81 | } |
| 82 | case East: case West:{ |
| 83 | float factor=0.5*(float)PipeWidth/(float)full(); |
| 84 | if (con==West) factor=-factor; |
| 85 | for (int i=0;i<full_level+Gran;i+=Gran) |
| 86 | vm->blit(ima, (int)(xof+(float)i*factor), yof); |
| 87 | } |
| 88 | default:break; |
| 89 | } |
| 90 | vm->enableClipping(false); |
| 91 | } |
| 92 | } |
| 93 |