00001 /* 00002 SagaEngine library 00003 Copyright (c) 2002-2006 Skalden Studio AS 00004 00005 This software is provided 'as-is', without any express or implied 00006 warranty. In no event will the authors be held liable for any 00007 damages arising from the use of this software. 00008 00009 Permission is granted to distribute the library under the terms of the 00010 Q Public License version 1.0. Be sure to read and understand the license 00011 before using the library. It should be included here, or you may read it 00012 at http://www.trolltech.com/products/qt/licenses/licensing/qpl 00013 00014 The original version of this library can be located at: 00015 http://www.sagaengine.com/ 00016 00017 Rune Myrland 00018 rune@skalden.com 00019 */ 00020 00021 00022 #include "CameraComponent.hpp" 00023 #include "sim/SimEngine.hpp" 00024 #include "sim/schema/SimSchema.hpp" 00025 #include "sim/area/Area.hpp" 00026 #include "sim/area/AreaManager.hpp" 00027 #include "sim/action/all.hpp" 00028 #include "sim/pos/PosComponent.hpp" 00029 #include "sim/zone/ZoneAreaComponent.hpp" 00030 #include "sim/thing/Actor.hpp" 00031 #include "sim/stat/Dictionary.hpp" 00032 #include "sim/stat/DictionaryEntry.hpp" 00033 #include "util/type/String.hpp" 00034 #include "util/error/Log.hpp" 00035 #include "../schema/ClientSchema.hpp" 00036 00037 00038 using namespace se_core; 00039 00040 namespace se_client { 00041 CameraComponent 00042 ::CameraComponent(Composite* owner) 00043 : Component(sct_CAMERA, owner), doesSee_(false) { 00044 posComponent_ = static_cast<PosComponent*>(owner_->component(sct_POS)); 00045 Assert(posComponent_); 00046 } 00047 00048 00049 CameraComponent 00050 ::~CameraComponent() { 00051 } 00052 00053 void CameraComponent 00054 ::setActive(bool state) { 00055 } 00056 00057 00058 void CameraComponent 00059 ::zoneChanged(int zoneType, Composite* newZone, Composite* oldZone) { 00060 if(zoneType == st_AREA && posComponent_ == ClientSchema::camera) { 00061 if(newZone) { 00062 LogWarning("Zone changed to : " << newZone->name()); 00063 SimSchema::areaManager.setActive(Area::Ptr(newZone), 2); 00064 ZoneAreaComponent::Ptr oZone(oldZone); 00065 ZoneAreaComponent::Ptr nZone(newZone); 00066 if(oZone.isNull() || oZone->page().w_ != nZone->page().w_) { 00067 const char* newLevel = SimSchema::dictionary().name(DE_ZONE, nZone->page().w_); 00068 SimSchema::simEngine.setLevel(newLevel); 00069 } 00070 } 00071 else { 00072 SimSchema::areaManager.resetActive(); 00073 } 00074 } 00075 00076 } 00077 00078 00079 void CameraComponent 00080 ::grabFocus() { 00081 if(posComponent_ == ClientSchema::camera) 00082 return; 00083 00084 Composite* oldArea = 0; 00085 if(ClientSchema::camera) { 00086 if(ClientSchema::camera->pos().hasArea()) { 00087 oldArea = const_cast<Composite*>(ClientSchema::camera->pos().area()->owner()); 00088 } 00089 } 00090 Composite* newArea = 0; 00091 if(posComponent_->pos().hasArea()) { 00092 newArea = const_cast<Composite*>(posComponent_->pos().area()->owner()); 00093 } 00094 00095 ClientSchema::camera = posComponent_; 00096 zoneChanged(st_AREA, newArea, oldArea); 00097 } 00098 00099 }
Home Page | SagaEngine trunk (updated nightly) reference generated Sun Dec 2 20:06:04 2007 by Doxygen version 1.3.9.1.