Add rate property.

This commit is contained in:
Nolan Darilek 2019-09-27 13:03:19 -05:00
parent bc46bbad60
commit ca79ca99bd
3 changed files with 41 additions and 12 deletions

View File

@ -8,5 +8,5 @@ edition = "2018"
crate-type = ["cdylib"]
[dependencies]
gdnative = { git = "https://github.com/ndarilek/godot-rust/" }
gdnative = { git = "https://github.com/GodotNativeTools/godot-rust/" }
tts = "0.2"

View File

@ -17,17 +17,14 @@ build: false
test_script:
- cargo build --release
# - cmd: mkdir -p staging\godot-tts\target\release
- cmd: copy target\release\*.dll staging\godot-tts\target\release
# - cmd: cd staging
# - cmd: 7z a ../windows.zip *
- sh: cp godot-tts.gdns staging/godot-tts
- sh: cp godot-tts.gdnlib.release staging/godot-tts/godot-tts.gdnlib
- sh: cp target/release/*.so target/godot-tts/target/release
- sh: cd target
- cmd: mkdir -p godot-tts\target\release
- cmd: copy target\release\*.dll godot-tts\target\release
- cmd: 7z a godot-tts-windows.zip godot-tts
- sh: cp godot-tts.gdns godot-tts
- sh: cp godot-tts.gdnlib.release godot-tts/godot-tts.gdnlib
- sh: cp target/release/*.so godot-tts/target/release
- sh: zip -r9 godot-tts.zip godot-tts/
- sh: appveyor PushArtifact godot-tts.zip
cache:
- target
- staging

View File

@ -1,11 +1,43 @@
use gdnative::*;
use gdnative::init::*;
use tts::{TTS as Tts};
#[derive(gdnative::NativeClass)]
#[inherit(gdnative::Node)]
struct TTS(Tts);
impl NativeClass for TTS {
type Base = Node;
type UserData = user_data::MutexData<TTS>;
fn class_name() -> &'static str {
"TTS"
}
fn init(owner: Self::Base) -> Self {
Self::_init(owner)
}
fn register_properties(builder: &ClassBuilder<Self>) {
builder.add_property(Property {
name: "rate",
default: 128,
hint: PropertyHint::Range {
range: 0.0..255.0,
step: 1.,
slider: true,
},
getter: |this: &TTS| {
let rate = this.0.get_rate().unwrap();
rate
},
setter: |this: &mut TTS, v: u8| {
this.0.set_rate(v).unwrap();
},
usage: PropertyUsage::DEFAULT,
});
}
}
#[methods]
impl TTS {
fn _init(_owner: gdnative::Node) -> Self {