Exemplo n.º 1
0
void Square::getViewIndex(const CreatureView* c, ViewIndex& ret) const {
  double fireSize = 0;
  if (creature && (c->canSee(creature) || creature->isPlayer())) {
    ret.insert(copyOf(creature->getViewObject()));
  }
  else if (creature && contains(c->getUnknownAttacker(), creature))
    ret.insert(copyOf(ViewObject::unknownMonster()));
  if (c->canSee(position)) {
    for (Item* it : inventory.getItems())
      fireSize = max(fireSize, it->getFireSize());
    fireSize = max(fireSize, fire.getSize());
    if (backgroundObject)
      ret.insert(*backgroundObject);
    ret.insert(getViewObject());
    for (const PTrigger& t : triggers)
      if (auto obj = t->getViewObject(c))
        ret.insert(copyOf(*obj).setAttribute(ViewObject::Attribute::BURNING, fireSize));
    if (Item* it = getTopItem())
      ret.insert(copyOf(it->getViewObject()).setAttribute(ViewObject::Attribute::BURNING, fireSize));
    ret.setHighlight(HighlightType::NIGHT, 1.0 - level->getLight(position));
    if (poisonGas.getAmount() > 0)
      ret.setHighlight(HighlightType::POISON_GAS, min(1.0, poisonGas.getAmount()));
    if (fog)
      ret.setHighlight(HighlightType::FOG, fog);
  } else
    ret.setHiddenId(getViewObject().id());
}
Exemplo n.º 2
0
void Square::setBackground(const Square* square) {
  dirty = true;
  if (getViewObject().layer() != ViewLayer::FLOOR_BACKGROUND) {
    const ViewObject& obj = square->backgroundObject ? (*square->backgroundObject) : square->getViewObject();
    if (obj.layer() == ViewLayer::FLOOR_BACKGROUND)
      backgroundObject = obj;
  }
}
Exemplo n.º 3
0
void PluginKateKJSWrapper::addView(Kate::MainWindow *win)
{
    PluginKateKJSWrapperView * view=getViewObject(win); // this is needed to ensure correct caching the javascript object
    KJS::Interpreter *js = m_part->interpreter();
    KJS::ExecState *exec = js->globalExec();
    exec->clearException();
    kdDebug()<<"****************************************************************************************"<<endl;
    kdDebug()<<"PluginKateKJSWrapper::addView"<<endl;
    kdDebug()<<"****************************************************************************************"<<endl;
    kdDebug()<<"checking for newWindowHandler"<<endl;
    if (!m_newWindowHandler.isNull()) {
    	KJS::List param;
	param.append(view->winObj);
	KJS::Object newWinFunc=m_newWindowHandler.toObject(exec);
	if (exec->hadException()) {
		exec->clearException();
	} else {
		if (newWinFunc.implementsCall()) {
			newWinFunc.call(exec,js->globalObject(),param);
			if (exec->hadException()) {
				kdDebug()<<"Error while calling newWindowHandler"<<endl;
				exec->clearException();
			}
		}
	}
    }
    if (exec->hadException()) kdDebug()<<"void PluginKateKJSWrapper::addView(Kate::MainWindow *win): exec had an exception - 1"<<endl;

    kdDebug()<<"checking for toolview constructors"<<endl;
    if (! (m_toolViewConstructors.isNull() || (m_toolViewConstructors.type()==KJS::NullType))) {
    	KJS::Object constrs=m_toolViewConstructors.toObject(exec);
	if (!exec->hadException()) {
		if (QString(constrs.classInfo()->className)=="Array") {
			kdDebug()<<"Toolview constructor array detected"<<endl;
			int size=constrs.get(exec,KJS::Identifier("length")).toInteger(exec);
			if (exec->hadException()) {
				exec->clearException(); 
				kdDebug()<<"Error while retrieving array length"<<endl;
			}
			else {
				for (int i=0;i<size;i++) {
					KJS::Object constrO=constrs.get(exec,i).toObject(exec);
					if (exec->hadException()) {
						exec->clearException();
					} else {
						KMDI::ToolViewAccessor *w=createToolView(m_part->factory(),js,win,view->winObj,constrO);
						if (w) {
							view->toolviews.append(QGuardedPtr<KMDI::ToolViewAccessor>(w));
						}
						exec->clearException();
					}
				}
			}
		} else {
			kdDebug()<<"Single toolview constructor detected"<<endl;
			if (!constrs.implementsConstruct()) {
				kdWarning()<<"wrong object type"<<endl;
			} else {
				KMDI::ToolViewAccessor *w=createToolView(m_part->factory(),js,win,view->winObj,constrs);
				if (w) {
					view->toolviews.append(QGuardedPtr<KMDI::ToolViewAccessor>(w));
				}
				exec->clearException();
			}
		}
	
	}
    } else kdDebug()<<"void PluginKateKJSWrapper::addView(Kate::MainWindow *win): no toolview constructors"<<endl;


    if (exec->hadException()) kdDebug()<<"void PluginKateKJSWrapper::addView(Kate::MainWindow *win): exec had an exception - 2"<<endl;

    view->setInstance (new KInstance("kate"));
    view->setXMLFile(QString("plugins/%1/%2.rc").arg(m_scriptname).arg(m_scriptname));
    win->guiFactory()->addClient (view);
}