/* * Copyright (C) 2004-2005 Vadim Berezniker * http://www.kryptolus.com * * This Program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This Program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GNU Make; see the file COPYING. If not, write to * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * http://www.gnu.org/copyleft/gpl.html * */ #include "stdafx.h" #include "common.h" kryEventDetailed::kryEventDetailed() { this->m_index = 0; this->m_layer = 0; this->m_marked = 0; this->m_margin_left = 0; this->m_margin_right = 0; this->m_margin_vertical = 0; this->m_style = kry_strdup("Default"); this->m_name = kry_strdup(""); this->m_prefix = NULL; this->m_effect = kry_strdup(""); this->m_collision_count = 0; this->m_collision_just_added = FALSE; this->m_collision_added = FALSE; this->m_collision_highlighted = FALSE; } kryEventDetailed::~kryEventDetailed() { if(this->m_style) kry_free(this->m_style); if(this->m_name) kry_free(this->m_name); if(this->m_effect) kry_free(this->m_effect); if(this->m_prefix) kry_free(this->m_prefix); } /* * Returns whether or not this event is marked. */ int kryEventDetailed::GetMarked() { return this->m_marked; } int kryEventDetailed::GetMarkedStatic(kryEventDetailed *event) { return event->GetMarked(); } void kryEventDetailed::SetMarked(int marked) { this->m_marked = marked; } void kryEventDetailed::SetMarkedStatic(kryEventDetailed *event, int marked) { event->SetMarked(marked); } /* * Returns the left margin of this event. */ int kryEventDetailed::GetMarginLeft() { return this->m_margin_left; } int kryEventDetailed::GetMarginLeftStatic(kryEventDetailed *event) { return event->GetMarginLeft(); } void kryEventDetailed::SetMarginLeft(int margin) { this->m_margin_left = margin; } void kryEventDetailed::SetMarginLeftStatic(kryEventDetailed *event, int margin) { event->SetMarginLeft(margin); } /* * Returns the right margin of this event. */ int kryEventDetailed::GetMarginRight() { return this->m_margin_right; } int kryEventDetailed::GetMarginRightStatic(kryEventDetailed *event) { return event->GetMarginRight(); } void kryEventDetailed::SetMarginRight(int margin) { this->m_margin_right = margin; } void kryEventDetailed::SetMarginRightStatic(kryEventDetailed *event, int margin) { event->SetMarginRight(margin); } /* * Returns the vertical margin of this event. */ int kryEventDetailed::GetMarginVertical() { return this->m_margin_vertical; } int kryEventDetailed::GetMarginVerticalStatic(kryEventDetailed *event) { return event->GetMarginVertical(); } void kryEventDetailed::SetMarginVertical(int margin) { this->m_margin_vertical = margin; } void kryEventDetailed::SetMarginVerticalStatic(kryEventDetailed *event, int margin) { event->SetMarginVertical(margin); } /* * Returns the layer of this event. */ int kryEventDetailed::GetLayer() { return this->m_layer; } int kryEventDetailed::GetLayerStatic(kryEventDetailed *event) { return event->GetLayer(); } void kryEventDetailed::SetLayer(int layer) { if(layer < 0) { g_warning("Attempt to set negative layer."); return; } if(layer != this->GetLayer()) { this->InvokeSignal(kryEvent::SIGNAL_BEFORE_LAYER_CHANGED, NULL); this->m_layer = layer; this->InvokeSignal(kryEvent::SIGNAL_AFTER_LAYER_CHANGED, NULL); } } void kryEventDetailed::SetLayerStatic(kryEventDetailed *event, int layer) { event->SetLayer(layer); } /* * Returns whether this line is in the collision list of the script it belongs to. */ gboolean kryEventDetailed::GetCollisionAdded() { return this->m_collision_added; } /* * Sets whether or not this line is in the collision list of the script it belongs to. */ void kryEventDetailed::SetCollisionAdded(gboolean val) { this->m_collision_added = val; } /* * Increases the collision count of this event. */ void kryEventDetailed::IncreaseCollisionCount() { this->m_collision_count++; } /* * Temporary flag used by kryScript during processing/ */ void kryEventDetailed::SetCollisionJustAdded(gboolean val) { this->m_collision_just_added = val; } /* * Returns the name of the event. */ char *kryEventDetailed::GetName() { return this->m_name; } char *kryEventDetailed::GetNameStatic(kryEventDetailed *event) { return event->GetName(); } /* * Set the name of the event. */ void kryEventDetailed::SetName(char *name) { if(!name) { g_warning("Attempt to set NULL name."); return; } if(this->m_name && !strcmp(this->m_name, name)) return; this->InvokeSignal(this->SIGNAL_BEFORE_NAME_CHANGED, NULL); if(this->m_name) kry_free(this->m_name); this->m_name = kry_strdup(name); this->InvokeSignal(this->SIGNAL_AFTER_NAME_CHANGED, NULL); } void kryEventDetailed::SetNameStatic(kryEventDetailed *event, char *name) { event->SetName(name); } /* * Get the prefix of the event. * The prefix is the extra text that is written to script before the event itself. * This is used to preserve identation in comments. */ char *kryEventDetailed::GetPrefix() { return this->m_prefix; } /* * Sets the prefix of the event. * The prefix is the extra text that is written to script before the event itself. * This is used to preserve identation in comments. */ void kryEventDetailed::SetPrefix(char *text) { if(this->m_prefix) kry_free(this->m_prefix); this->m_prefix = kry_strdup(text); } /* * Returns the style of the event. */ char *kryEventDetailed::GetStyle() { return this->m_style; } char *kryEventDetailed::GetStyleStatic(kryEventDetailed *event) { return event->GetStyle(); } /* * Sets the style of the event. */ void kryEventDetailed::SetStyle(char *name) { if(!name) { g_warning("Attempt to set NULL name."); return; } if(this->m_style) kry_free(this->m_style); this->m_style = kry_strdup(name); } void kryEventDetailed::SetStyleStatic(kryEventDetailed *event, char *name) { event->SetStyle(name); } /* * Returns the effect string of the event. */ char *kryEventDetailed::GetEffect() { return this->m_effect; } char *kryEventDetailed::GetEffectStatic(kryEventDetailed *event) { return event->GetEffect(); } /* * Sets the effect string of the event. */ void kryEventDetailed::SetEffect(char *effect) { if(!effect) { g_warning("Attempt to set NULL effect."); return; } if(this->m_effect) kry_free(this->m_effect); this->m_effect = kry_strdup(effect); } void kryEventDetailed::SetEffectStatic(kryEventDetailed *event, char *effect) { event->SetEffect(effect); } /* * Sets the collision count of this event. */ void kryEventDetailed::SetCollisionCount(int count) { if(count < 0) { g_warning("Attempt to set negative collision count."); return; } this->m_collision_count = count; } /* * Returns the collision count of this event. */ int kryEventDetailed::GetCollisionCount() { return this->m_collision_count; } /* * Temporary flag used by kryScript during processing. */ gboolean kryEventDetailed::GetCollisionJustAdded() { return this->m_collision_just_added; } /* * Decreases the collision count of the event. */ void kryEventDetailed::DecreaseCollisionCount() { if(this->m_collision_count == 0) { g_warning("Attempt to decrease collision count below 0"); return; } this->m_collision_count--; } /* * Sets whether or not the event is highlighted in the event list. */ void kryEventDetailed::SetCollisionHighlighted(gboolean val) { this->m_collision_highlighted = val; } /* * Gets whether or not the event is highlighted in the event list. */ gboolean kryEventDetailed::GetCollisionHighlighted() { return this->m_collision_highlighted; } /* * Makes a copy of the event list. * NOTE: The copy does not have any signals connected. */ kryEventDetailed *kryEventDetailed::Copy() { kryEventDetailed *new_event = new kryEventDetailed(); if(new_event->m_text) kry_free(new_event->m_text); if(new_event->m_effect) kry_free(new_event->m_effect); if(new_event->m_style) kry_free(new_event->m_style); if(new_event->m_name) kry_free(new_event->m_name); *new_event = *this; new_event->m_effect = NULL; new_event->m_text = NULL; new_event->m_style = NULL; new_event->m_name = NULL; new_event->m_prefix = NULL; new_event->SetEffect(this->GetEffect()); new_event->SetStyle(this->GetStyle()); if(this->GetName()) new_event->SetName(this->GetName()); if(this->GetText()) new_event->SetText(this->GetText()); if(this->GetPrefix()) new_event->SetPrefix(this->GetPrefix()); new_event->m_collision_added = FALSE; new_event->m_collision_count = 0; new_event->m_collision_highlighted = FALSE; new_event->m_collision_just_added = FALSE; return new_event; } gboolean kryEventDetailed::IsDetailed() { return TRUE; }